Skip to content

Commit 8f8b657

Browse files
authored
ci: use ref or sha as version in deploy workflows (#196)
ci: use GITHUB_OUTPUT environment file
1 parent 133165e commit 8f8b657

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/deploy-prod.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@ jobs:
2929
- name: Yarn install and Cache dependencies
3030
uses: graasp/graasp-deploy/.github/actions/yarn-install-and-cache@v1
3131

32+
- name: Set version
33+
id: set-version
34+
run: |
35+
VERSION_REPO_DISPATCH=${{ github.event.client_payload.tag }}
36+
VERSION_REF=${{ github.ref_name }}
37+
VERSION_COMMIT=${{ github.sha }}
38+
echo "VERSION=${VERSION_REPO_DISPATCH:-${VERSION_REF:-${VERSION_COMMIT:-"undefined"}}}" >> "$GITHUB_OUTPUT"
39+
3240
- name: Yarn build
3341
# Set environment variables required to perform the build. These are only available to this step
3442
env:
3543
VITE_API_HOST: ${{ vars.API_HOST }}
3644
VITE_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
3745
VITE_SENTRY_ENV: ${{ vars.SENTRY_ENV }}
3846
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
39-
VITE_VERSION: ${{ github.event.client_payload.tag }}
47+
VITE_VERSION: ${{ steps.set-version.outputs.VERSION }}
4048
VITE_WS_HOST: ${{ vars.WS_HOST }}
4149
# add any env variable needed by your app here
4250
run: yarn build

.github/workflows/deploy-stage.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@ jobs:
2929
- name: Yarn install and Cache dependencies
3030
uses: graasp/graasp-deploy/.github/actions/yarn-install-and-cache@v1
3131

32+
- name: Set version
33+
id: set-version
34+
run: |
35+
VERSION_REPO_DISPATCH=${{ github.event.client_payload.tag }}
36+
VERSION_REF=${{ github.ref_name }}
37+
VERSION_COMMIT=${{ github.sha }}
38+
echo "VERSION=${VERSION_REPO_DISPATCH:-${VERSION_REF:-${VERSION_COMMIT:-"undefined"}}}" >> "$GITHUB_OUTPUT"
39+
3240
- name: Yarn build
3341
# Set environment variables required to perform the build. These are only available to this step
3442
env:
3543
VITE_API_HOST: ${{ vars.API_HOST }}
3644
VITE_GRAASP_APP_KEY: ${{ secrets.APP_KEY }}
3745
VITE_SENTRY_ENV: ${{ vars.SENTRY_ENV }}
3846
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
39-
VITE_VERSION: ${{ github.event.client_payload.tag }}
47+
VITE_VERSION: ${{ steps.set-version.outputs.VERSION }}
4048
VITE_WS_HOST: ${{ vars.WS_HOST }}
4149
# add any env variable needed by your app here
4250
run: yarn build

0 commit comments

Comments
 (0)