.github/workflows/publish.yaml #7
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
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
push_to_registry: | |
name: Push Docker image to gchr.io | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Set Environment Variables | |
run: | | |
echo "runner_arch=$(uname -m)" | tee -a $GITHUB_ENV | |
echo "driver_name=$(echo $GITHUB_REF | perl -n -e '/refs\/tags\/([^-]+)-v(.+)/ && print $1')" | tee -a $GITHUB_ENV | |
echo "driver_version=$(echo $GITHUB_REF | perl -n -e '/refs\/tags\/([^-]+)-v(.+)/ && print $2')" | tee -a $GITHUB_ENV | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/hsm-drivers | |
- name: build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ${{ env.driver_name }}.Dockerfile | |
cache-from: type=gha | |
cache-to: type=gha | |
push: ${{ startsWith(github.ref, 'refs/tags/') }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |