Repository navigation
50 lines (50 loc) · 1.76 KB
/
Copy pathdocker-publish.yml
File metadata and controls
50 lines (50 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: docker-publish
# Publishes the HAXcms PHP platform image to GitHub Container Registry
# (haxtheweb/issues#2814). Uses the built-in GITHUB_TOKEN; no extra secrets.
#
# ghcr.io/haxtheweb/haxcms-php:<version> on every MAJOR.MINOR.PATCH tag
# ghcr.io/haxtheweb/haxcms-php:latest moves with the newest release tag
# ghcr.io/haxtheweb/haxcms-php:sha-<short> manual runs from a branch
on:
push:
# same tag shapes as release.yml (bare and v-prefixed)
tags:
- "[0-9]*.[0-9]*.[0-9]*"
- "v[0-9]*.[0-9]*.[0-9]*"
workflow_dispatch:
permissions:
contents: read
env:
IMAGE_NAME: ghcr.io/haxtheweb/haxcms-php
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # push to ghcr.io with GITHUB_TOKEN
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Log in to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Derive image tags
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,enable=${{ github.ref_type != 'tag' }}
- name: Build and push
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}