Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
ci: change logic to get sha and ref
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandogelin committed Jul 20, 2020
1 parent 70e785c commit ecd84fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_at_home.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
- name: npm build
run: npm run build:win:home
env:
CI: true
REACT_APP_AT_HOME: true

# Build electron app package installers
Expand Down
18 changes: 14 additions & 4 deletions version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
const fs = require('fs-extra')
const execa = require('execa');

const rev = execa.commandSync('git rev-parse HEAD').stdout
const branch = execa.commandSync('git branch --show-current').stdout
const git = {rev, branch}
let git;

if (process.env.CI) {
const sha = process.env.GITHUB_SHA
const ref = process.env.GITHUB_REF
git = {sha, ref}
}
else {
const sha = execa.commandSync('git rev-parse HEAD').stdout
const ref = execa.commandSync('git branch --show-current').stdout
git = {sha, ref}
}


fs.writeFile('public/config/version.json', JSON.stringify(git))
.then(() => {
console.log(`Saved version file with rev: ${git.rev}, branch: ${git.branch}`);
console.log(`Saved version file with rev: ${git.sha}, branch: ${git.ref}`);
})
.catch((err) => {
console.log(err);
Expand Down

0 comments on commit ecd84fb

Please sign in to comment.