Skip to content

Commit

Permalink
Improve security and use latest tag for main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dippynark committed Dec 28, 2023
1 parent ac37b66 commit c2dcc8f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate tag
run: |
set -euo pipefail
# https://github.com/github/docs/issues/15319#issuecomment-1662257301
TAG="${{ github.event.pull_request && github.head_ref || github.ref_name }}"
if [ "$TAG" = "main" ]; then
TAG=latest
fi
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Build and push
uses: docker/build-push-action@v5
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
env:
# https://github.com/github/docs/issues/15319#issuecomment-1662257301
BRANCH: ${{ github.event.pull_request && github.head_ref || github.ref_name }}
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cost-manager:${{ env.TAG }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cost-manager:${{ env.BRANCH == 'main' && 'latest' || env.BRANCH }}

0 comments on commit c2dcc8f

Please sign in to comment.