fix environment path in release workflow #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Release | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
release: | |
uses: codingones/github-actions-workflows/.github/workflows/semantic-release.yml@main | |
with: | |
package-manager: 'yarn' | |
install-dependencies-command: 'yarn install --frozen-lockfile' | |
cache-dependency-path: 'yarn.lock' | |
secrets: | |
PAT: ${{ secrets.PAT }} | |
deploy-artifact-to-s3: | |
needs: | |
- release | |
name: Generate and deploy artifact to s3 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout client-application repository | |
uses: actions/checkout@v3 | |
# TODO Better way to manage env generation | |
- name: Release (Generate environment.ts file) | |
run: | | |
echo "export const ENV = { | |
auth: { | |
clientId: '${{ vars.COGNITO_APP_INTEGRATION_ID }}' | |
} | |
};" > src/environments/environment.ts | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 'lts/*' | |
cache: 'yarn' | |
cache-dependency-path: 'yarn.lock' | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: | | |
yarn build client | |
# TODO Convert this into a semantic-release step one day | |
- name: Deploy | |
uses: kersvers/s3-sync-with-cloudfront-invalidation@v1.0.0 | |
with: | |
args: --delete | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_S3_BUCKET: ${{ vars.CLOUDFRONT_S3_BUCKET }} | |
DISTRIBUTION_ID: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }} | |
SOURCE_DIR: 'dist/client' | |
notify-on-error: | |
needs: | |
- deploy-artifact-to-s3 | |
- release | |
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} | |
uses: codingones/github-actions-workflows/.github/workflows/notify-discord.yml@main | |
with: | |
bot-username: Failures Bot | |
notification-content: 'A release has failed for ${{ github.repository }} this should not happen, invest some time in your CI/CD ?' | |
embed-title: Go to the workflow | |
embed-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
secrets: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_FAILURES_WEBHOOK }} | |
notify-on-success: | |
needs: | |
- deploy-artifact-to-s3 | |
- release | |
if: ${{ always() && needs.release.result == 'success' && needs.deploy-artifact-to-s3.result == 'success' }} | |
uses: codingones/github-actions-workflows/.github/workflows/notify-discord.yml@main | |
with: | |
bot-username: Releases Bot | |
notification-content: 'A new ${{ github.repository }} version: ${{ needs.release.outputs.version }} has been released ! :tada:' | |
embed-title: Go to the changelog | |
embed-url: https://github.com/${{ github.repository }}/blob/main/docs/CHANGELOG.md | |
secrets: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }} |