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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Publish Special Containers | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- next | |
- main | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build: | |
name: Build & Publish Containers | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
max-parallel: 1 | |
matrix: | |
include: | |
- image: mysql | |
path: containers/mysql | |
description: MySQL is a widely used, open-source relational database management system (RDBMS). | |
version: | |
short: 9 | |
full: 9.1.0 | |
- image: nginx | |
path: containers/nginx | |
description: Official build of Nginx. | |
version: | |
short: 1 | |
full: '1.27-alpine' | |
- image: wordpress | |
path: containers/wordpress | |
description: The WordPress rich content management system can utilize plugins, widgets, and themes. | |
version: | |
short: 6 | |
full: 6.6-php8.2-fpm-alpine | |
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/[email protected] | |
- name: 🏗 Extract Docker metadata | |
id: meta | |
uses: docker/[email protected] | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
images: | | |
name=${{env.REGISTRY}}/gecut/lemp/${{matrix.image}},enable=false | |
name=${{env.REGISTRY}}/${{github.repository_owner}}/lemp/${{matrix.image}},enable=true | |
labels: | | |
[email protected] | |
org.opencontainers.image.title=@Gecut/${{matrix.image}} | |
org.opencontainers.image.description=${{matrix.description}} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=raw,value=${{matrix.version.short}} | |
type=raw,value=${{matrix.version.full}} | |
# type=semver,pattern={{version}},prefix=alwatr- | |
# type=semver,pattern={{major}}.{{minor}},prefix=alwatr- | |
- name: 🏗 Install cosign | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: sigstore/[email protected] | |
- name: 🏗 Setup Docker Buildx | |
uses: docker/[email protected] | |
- name: 🏗 Log into registry ${{env.REGISTRY}} | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/[email protected] | |
with: | |
registry: ${{env.REGISTRY}} | |
username: ${{github.repository_owner}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: 🚀 Build and push container image | |
id: build-and-push | |
uses: docker/[email protected] | |
with: | |
context: ${{matrix.path}} | |
push: ${{github.event_name != 'pull_request'}} | |
tags: ${{steps.meta.outputs.tags}} | |
labels: ${{steps.meta.outputs.labels}} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: 🏗 Sign the published container image | |
if: ${{github.event_name != 'pull_request'}} | |
env: | |
COSIGN_EXPERIMENTAL: 'true' | |
run: echo "${{steps.meta.outputs.tags}}" | xargs -I {} cosign sign --yes {}@${{steps.build-and-push.outputs.digest}} |