Skip to content

Commit

Permalink
Push latest on main
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrizic committed Mar 3, 2024
1 parent 194c792 commit eb4d457
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ jobs:
run: docker build . --file Dockerfile --tag ghcr.io/prodyna/deployment-overview:latest

# if tag, get the tag as variable
- name: Set env
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Get tag if available
if: startsWith(github.ref, 'refs/tags/v')
run: echo "tag=${GITHUB_REF#refs/tags/*}" >> $GITHUB_ENV

# if tagged, create docker tag
- name: Create a tag for the Docker image
if: github.ref == 'refs/heads/main'
run: docker tag ghcr.io/prodyna/deployment-overview:latest ghcr.io/prodyna/deployment-overview:${{ env.tag }}
# Login to the GitHub Container Registry
- name: Login to the GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }}

# Push latest to GitHub Container Registry
- name: Push the latest Docker image to the GitHub Container Registry
run: docker push ghcr.io/prodyna/deployment-overview:latest

# if tagged, push the image to the GitHub Container Registry
- name: Push the Docker image to the GitHub Container Registry
if: github.ref == 'refs/heads/main'
run: docker push ghcr.io/prodyna/deployment-overview:${{ env.tag }}
- name: Push the tagged Docker image to the GitHub Container Registry
if: startsWith(github.ref, 'refs/tags/v')
run: |
docker tag ghcr.io/prodyna/deployment-overview:latest ghcr.io/prodyna/deployment-overview:${{ env.tag }}
docker push ghcr.io/prodyna/deployment-overview:${{ env.tag }}

0 comments on commit eb4d457

Please sign in to comment.