Skip to content

Commit

Permalink
ci: update Deploy workflow to tag-based
Browse files Browse the repository at this point in the history
  • Loading branch information
lalver1 committed Jul 11, 2024
1 parent 650537a commit 716a323
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@ on:
push:
branches:
- main
- test
- prod
tags:
# pre-release tag
- "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+"
# release tags
- "202[3-9].[0-9][0-9].[0-9]+"

env:
# this ternary operator like expression gives us the name of the deployment environment (see https://docs.github.com/en/actions/learn-github-actions/expressions#example)
DEPLOY_ENV: ${{ github.ref_type != 'tag' && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}

defaults:
run:
shell: bash

concurrency:
group: ${{ env.DEPLOY_ENV }}
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
concurrency: ${{ github.ref_name }}
environment: ${{ env.DEPLOY_ENV }}

steps:
- name: Checkout
Expand Down Expand Up @@ -69,3 +79,23 @@ jobs:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
images: ghcr.io/${{ github.repository }}:${{ github.sha }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}

release:
needs: deploy
if: ${{ env.DEPLOY_ENV == 'prod'}}
runs-on: ubuntu-latest
permissions:
# https://github.com/softprops/action-gh-release#permissions
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Release
uses: softprops/action-gh-release@v2
with:
prerelease: false
generate_release_notes: true

0 comments on commit 716a323

Please sign in to comment.