Update docker-publish.yml #259
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 Push | ||
concurrency: docker-publish | ||
on: | ||
schedule: | ||
- cron: '23 4 */7 * *' | ||
push: | ||
branches: [ main ] | ||
tags: | ||
- v* | ||
paths-ignore: | ||
- README.md | ||
pull_request: | ||
branches: [ main ] | ||
env: | ||
REGISTRY: docker.io | ||
IMAGE_NAME: ${{ secrets.DOCKERHUB_USER }}/backblaze-personal-wine | ||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
# Workaround: https://github.com/docker/build-push-action/issues/461 | ||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@28218f9b04b4f3f62068a23c75a09a9a85e35ff7d | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
# Build and push Docker image | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb3375089b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
file: ${FILE} | ||
platforms: linux/amd64 | ||
# Special tagging for Ubuntu 22, 20, and 18 | ||
tags: |{% if FILE == 'Dockerfile.ubuntu22' %} | ||
{{ steps.meta.outputs.tags }} | ||
{{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main | ||
{{ env.REGISTRY }}/${{ envIMAGE_NAME }}:latest | ||
{{ env.REGISTRY }}/${{ envIMAGE_NAME }}:v*{% if github.ref == 'refs/heads/main' %}:{% endif %} | ||
{% elsif FILE == 'Dockerfile.ubuntu20' %} | ||
{{ steps.meta.outputs.tags }} | ||
{{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main | ||
{{ env.REGISTRY }}/${{ envIMAGE_NAME }}:latest{% if github.ref != 'refs/heads/main' %}:{% endif %} | ||
{% elsif FILE == 'Dockerfile.ubuntu18' %} | ||
{{ steps.meta.outputs.tags }} | ||
{{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main | ||
{{ env.REGISTRY }}/${{ envIMAGE_NAME }}:v*{% if github.ref != 'refs/heads/main' %}:{% endif %} | ||
{% else %} | ||
{{ steps.meta.outputs.tags }} | ||
{% endif %} | ||
labels: ${steps.meta.outputs.labels} |