docker flow #3
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 publish Docker images | |
#on: | |
# push: | |
# branches: | |
# - main | |
# - master | |
# tags: | |
# - 'v*' | |
# release: | |
# types: [published] | |
on: | |
pull_request: | |
push: | |
jobs: | |
latest: | |
runs-on: ubuntu-22.04 | |
if: ${{ ! startsWith(github.ref, 'refs/tags/') }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Packages | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta for latest | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/lablabs/aws-service-quotas-exporter | |
tags: | | |
type=raw,value=latest | |
- name: Docker meta for tag | |
if: startsWith(github.ref, 'refs/tags/') | |
id: meta-tag | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/lablabs/aws-service-quotas-exporter | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=${{ github.ref_name }} | |
- name: Build image and push to GitHub Container Registry | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
tag: | |
runs-on: ubuntu-22.04 | |
if: ${{ ! startsWith(github.ref, 'refs/tags/') }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Packages | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta for latest | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/lablabs/aws-service-quotas-exporter | |
tags: | | |
type=raw,value=latest | |
- name: Build image and push to GitHub Container Registry | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |