Docker #29
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: Docker Build and Publish | |
"on": | |
push: | |
branches: ["main"] | |
tags: ['v*.*.*'] | |
pull_request: | |
branches: ["main"] | |
env: | |
REGISTRY: docker.io | |
RUSTYGATE_IMAGE: 3loc/rustygate | |
TESTS_IMAGE: 3loc/rustygate-tests | |
PLATFORMS: linux/amd64,linux/arm64 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: tedostrem | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract Docker metadata for RustyGate | |
id: meta-rustygate | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.RUSTYGATE_IMAGE }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Extract Docker metadata for Tests | |
id: meta-tests | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.TESTS_IMAGE }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build and push RustyGate image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ env.PLATFORMS }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-rustygate.outputs.tags }} | |
labels: ${{ steps.meta-rustygate.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build and push Tests image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ env.PLATFORMS }} | |
file: tests/python/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-tests.outputs.tags }} | |
labels: ${{ steps.meta-tests.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |