Skip to content

Docker

Docker #771

Workflow file for this run

# Copyright 2023 Wayback Archiver. All rights reserved.
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file.
name: Docker
on:
schedule:
- cron: '0 0 * * *'
push:
tags:
- v*
branches:
- 'main'
- 'develop'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
publish:
name: Build and push Docker image
runs-on: ubuntu-latest
permissions:
packages: write
id-token: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34 # v1.5.0
with:
egress-policy: block
disable-telemetry: true
allowed-endpoints: >
ghcr.io:443
github.com:443
api.github.com:443
pkg-containers.githubusercontent.com:443
docker.io:443
auth.docker.io:443
index.docker.io:443
registry-1.docker.io:443
production.cloudflare.docker.com:443
dl-cdn.alpinelinux.org:443
registry.yarnpkg.com:443
registry.npmjs.org:443
- name: Checkout default branch
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
fetch-depth: 0
- name: Prepare
id: prep
run: |
GHCR_HOST=ghcr.io
DOCKER_IMAGE_SCOPE=${{ github.repository }} # foo/bar
if [ "${{ github.event_name }}" = "schedule" ]; then
DOCKER_IMAGE_VERSION=nightly
elif [[ $GITHUB_REF == refs/tags/* ]]; then
DOCKER_IMAGE_VERSION=${GITHUB_REF#refs/*/v}
TAGS="${DOCKER_IMAGE_SCOPE}:latest,${GHCR_HOST}/${DOCKER_IMAGE_SCOPE}:latest"
else
DOCKER_IMAGE_VERSION=dev
fi
TAGS="${TAGS},${DOCKER_IMAGE_SCOPE}:${DOCKER_IMAGE_VERSION},${GHCR_HOST}/${DOCKER_IMAGE_SCOPE}:${DOCKER_IMAGE_VERSION}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # 2.5.0
- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.1.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: ${{ steps.prep.outputs.tags }}