fix tags in docker_meta step #2
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
# Build Docker image and push to Docker Hub | |
name: build-and-push-docker-image | |
on: | |
workflow_dispatch: # Supports manual triggering | |
push: | |
branches: [ main ] | |
env: | |
DOCKER_IMAGE: ohdsi/broadsea-atlasdb | |
jobs: | |
# Build Docker container and push to Docker Hub | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Extract Docker metadata (tags, labels) | |
id: docker_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.DOCKER_IMAGE }} | |
tags: | | |
type=semver,pattern={{version}} # Tag based on Git semantic version tag (e.g., "2.2.0") | |
type=sha # Tag based on commit SHA (e.g., "mycontainer:<commit-sha>") | |
type=raw,value=latest # Static "latest" tag | |
labels: | | |
org.opencontainers.image.version={{version}} | |
org.opencontainers.image.source={{source}} | |
org.opencontainers.image.created={{timestamp}} | |
org.opencontainers.image.revision={{sha}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set build parameters | |
id: build_params | |
run: | | |
echo "sha8=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT | |
echo "push=false" >> $GITHUB_OUTPUT | |
echo "load=false" >> $GITHUB_OUTPUT | |
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max | |
platforms: ${{ steps.build_params.outputs.platforms }} | |
push: ${{ steps.build_params.outputs.push }} | |
load: ${{ steps.build_params.outputs.load }} | |
build-args: | | |
GIT_BRANCH=${{ steps.docker_meta.outputs.version }} | |
GIT_COMMIT_ID_ABBREV=${{ steps.build_params.outputs.sha8 }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: | | |
${{ steps.docker_meta.outputs.labels }} | |
org.opencontainers.image.authors=Lee Evans - www.ltscomputingllc.com | |
org.opencontainers.image.vendor=OHDSI | |
org.opencontainers.image.licenses=Apache-2.0 | |
- name: Log generated Docker image tags | |
id: log_tags | |
run: | | |
echo "Generated tags: ${{ steps.docker_meta.outputs.tags }}" | |
echo "Generated labels: ${{ steps.docker_meta.outputs.labels }}" | |
# - name: Inspect image | |
# run: | | |
# docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} |