ci: use docker/metadata-action and build-push-action
All checks were successful
Build and Deploy / Build & Push (push) Successful in 14m31s
All checks were successful
Build and Deploy / Build & Push (push) Successful in 14m31s
Cleaner pipeline using official Docker actions. Supports semver tags alongside latest. Registry driven by vars.REGISTRY variable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,40 +4,37 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-push:
|
||||||
|
name: Build & Push
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set image tags
|
- name: Docker metadata
|
||||||
id: image
|
id: meta
|
||||||
run: |
|
uses: docker/metadata-action@v5
|
||||||
# Gitea's container registry lives on the same host as the Gitea instance
|
with:
|
||||||
REGISTRY="${{ gitea.server_url }}"
|
images: ${{ vars.REGISTRY }}/${{ gitea.repository_owner }}/sixflagssupercalendar
|
||||||
REGISTRY="${REGISTRY#https://}"
|
tags: |
|
||||||
REGISTRY="${REGISTRY#http://}"
|
type=semver,pattern={{version}}
|
||||||
IMAGE="${REGISTRY}/josh/sixflagssupercalendar"
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
SHA="${{ gitea.sha }}"
|
|
||||||
echo "registry=${REGISTRY}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "tag_latest=${IMAGE}:latest" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "tag_sha=${IMAGE}:${SHA::8}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Log in to registry
|
- name: Log in to Gitea registry
|
||||||
run: |
|
uses: docker/login-action@v3
|
||||||
echo "${{ secrets.REGISTRY_TOKEN }}" | \
|
with:
|
||||||
docker login "${{ steps.image.outputs.registry }}" -u josh --password-stdin
|
registry: ${{ vars.REGISTRY }}
|
||||||
|
username: ${{ gitea.actor }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Build image
|
- name: Build and push
|
||||||
run: |
|
uses: docker/build-push-action@v6
|
||||||
docker build \
|
with:
|
||||||
-t "${{ steps.image.outputs.tag_latest }}" \
|
context: .
|
||||||
-t "${{ steps.image.outputs.tag_sha }}" \
|
push: true
|
||||||
.
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
- name: Push image
|
|
||||||
run: |
|
|
||||||
docker push "${{ steps.image.outputs.tag_latest }}"
|
|
||||||
docker push "${{ steps.image.outputs.tag_sha }}"
|
|
||||||
|
|||||||
@@ -116,11 +116,10 @@ The pipeline is defined at [`.gitea/workflows/deploy.yml`](.gitea/workflows/depl
|
|||||||
|
|
||||||
| Type | Name | Value |
|
| Type | Name | Value |
|
||||||
|------|------|-------|
|
|------|------|-------|
|
||||||
|
| Variable | `REGISTRY` | Registry hostname — `gitea.thewrightserver.net` |
|
||||||
| Secret | `REGISTRY_TOKEN` | A Gitea access token with `package:write` scope |
|
| Secret | `REGISTRY_TOKEN` | A Gitea access token with `package:write` scope |
|
||||||
|
|
||||||
Set this under **Repository → Settings → Actions → Secrets**.
|
Set these under **Repository → Settings → Actions → Variables / Secrets**.
|
||||||
|
|
||||||
The registry host is derived automatically from `gitea.server_url` — no `REGISTRY_URL` variable needed.
|
|
||||||
|
|
||||||
#### Upstream remote
|
#### Upstream remote
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user