Gut ghcr.io usage for this 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 Custom Images | |
on: | |
push: | |
schedule: | |
- cron: '0 11 * * *' | |
concurrency: | |
group: ${{ github.event_name}}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-docker-image-base: | |
runs-on: ubuntu-20.04 | |
name: "Build Docker images" | |
strategy: | |
matrix: | |
include: | |
- image: tf2 | |
platform: linux/amd64 | |
file: tf2/Dockerfile | |
permissions: | |
contents: read | |
packages: write | |
environment: Release | |
env: | |
REGISTRY: ${{ vars.REGISTRY }} | |
REGISTRY_USERNAME: ${{ vars.REGISTRY_USERNAME }} | |
REGISTRY_PASSWORD: ${{ vars.REGISTRY_PASSWORD }} | |
steps: | |
- name: Ensure mask | |
id: values | |
run: | | |
echo "::add-mask::$REGISTRY_USERNAME" | |
echo "::add-mask::$REGISTRY_PASSWORD" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
if: ${{ env.REGISTRY_USERNAME != '' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ env.REGISTRY_USERNAME }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
name=pufferpanel/${{ matrix.image }} | |
flavor: | | |
latest=true | |
tags: | | |
type=schedule,pattern={{date 'YYYYMMDD-hhmmss'}} | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ${{ matrix.file }} | |
push: ${{ github.event_name != 'pull_request' && env.REGISTRY_USERNAME != '' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: ${{ matrix.platform }} |