Skip to content

Commit

Permalink
chore: Set up tags in CD workflow for different branches
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeraa committed Jul 14, 2024
1 parent fadd76b commit f0ce8ce
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,21 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Set up tags
id: vars
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
echo "LATEST_TAG=ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest" >> $GITHUB_ENV
echo "SHA_TAG=ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.sha }}-${{ github.run_number }}" >> $GITHUB_ENV
else
echo "SHA_TAG=ghcr.io/${{ env.IMAGE_REPOSITORY }}:beta-${{ github.sha }}-${{ github.run_number }}" >> $GITHUB_ENV
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
build-args: |
GH_NPM_TOKEN=${{ secrets.GITHUB_TOKEN }}
push: true
tags: |
${{ github.ref_name == 'main' && 'ghcr.io/' || '' }}${{ env.IMAGE_REPOSITORY }}${{ github.ref_name == 'main' && ':latest' || '' }}
${{ github.ref_name == 'main' && 'ghcr.io/' || '' }}${{ env.IMAGE_REPOSITORY }}${{ github.ref_name == 'main' && ':${{ github.sha }}-${{ github.run_number }}' || ':beta-${{ github.sha }}-${{ github.run_number }}' }}
${{ env.LATEST_TAG }}
${{ env.SHA_TAG }}

0 comments on commit f0ce8ce

Please sign in to comment.