Skip to content

Docker

Docker #58

name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
schedule:
- cron: "45 5 * * *"
push:
branches:
- main
paths-ignore:
- README.md
pull_request:
branches:
- main
env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: jessebot/pixelfed-glitch
jobs:
get-tags:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
output1: ${{ steps.pixelfed-glitch-release.outputs.release }}
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
# this just gets the latest pixelfed-glitch release
- id: pixelfed-glitch-release
name: Get latest pixelfed-glitch/pixelfed release
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: pixelfed-glitch
repo: pixelfed
excludes: prerelease, draft
build:
needs: get-tags
continue-on-error: true
strategy:
matrix:
branch:
- develop
- main
- ${{needs.get-tags.outputs.output1}}
webserver:
- nginx
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.8.0
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: docker_meta
uses: docker/metadata-action@v5.6.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.branch }}
flavor: |
suffix=-${{ matrix.webserver }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6.12.0
with:
context: .
build-args: |
BRANCH=${{ matrix.branch }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.${{ matrix.webserver }}
platforms: linux/amd64,linux/arm64