tag image with git tag #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image | |
# Check https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token | |
# TODO: add docker layer caching | |
on: | |
push: | |
tags: | |
- 'container-release/*' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
# Checkout the repository | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Log in to GitHub Container Registry | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Build the Docker image | |
- name: Build Docker image | |
run: | | |
docker build -t ghcr.io/${{ github.repository_owner }}/acme-metaflow:latest . | |
# Push the Docker image to GHCR | |
- name: Push Docker image with tag | |
run: | | |
IMAGE_TAG=${GITHUB_REF#refs/tags/container-release/} | |
docker tag ghcr.io/${{ github.repository_owner }}/acme-metaflow:latest ghcr.io/${{ github.repository_owner }}/acme-metaflow:${IMAGE_TAG} | |
docker push ghcr.io/${{ github.repository_owner }}/acme-metaflow:${IMAGE_TAG} | |
docker push ghcr.io/${{ github.repository_owner }}/acme-metaflow:latest |