From b6f215514e152e6cd9bfc42dac67740806a7e1ca Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Tue, 15 Oct 2024 14:30:10 -0700 Subject: [PATCH] 1473: Create a git tag after deploying (#315) --- .github/workflows/deploy.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6e37dffb..44261afb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest needs: [database-migrations] permissions: - contents: read + contents: write id-token: write steps: - uses: actions/checkout@v4 @@ -48,3 +48,19 @@ jobs: - name: Deploy release working-directory: . run: make release-deploy APP_NAME=${{ inputs.app_name }} ENVIRONMENT=${{ inputs.environment }} + + - name: Push git tag with timestamp + if: success() + run: | + # Create a tag like "deploy/prod/2024-10-09-11:00:00". + # + # Skip tagging in "dev" environment (our demo site) since we deploy + # on every commit. + if [ "${{ inputs.environment }}" != "dev" ]; then + export TZ="America/New_York" + TAG_NAME="deploy/${{ inputs.environment }}/$(date +'%Y-%m-%d-%H:%M:%S')" + git config --local user.name "github-actions" + git config --local user.email "github-actions@github.com" + git tag "$TAG_NAME" + git push origin "$TAG_NAME" + fi