From ecd84fb1947b93efe474209a25eaea02686cd290 Mon Sep 17 00:00:00 2001 From: fernandogelin Date: Mon, 20 Jul 2020 13:39:13 -0400 Subject: [PATCH] ci: change logic to get sha and ref --- .github/workflows/build_at_home.yaml | 1 - version.js | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_at_home.yaml b/.github/workflows/build_at_home.yaml index 437d968..ed98384 100644 --- a/.github/workflows/build_at_home.yaml +++ b/.github/workflows/build_at_home.yaml @@ -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 diff --git a/version.js b/version.js index 415c511..e2cc933 100644 --- a/version.js +++ b/version.js @@ -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);