Match towerops CI pattern for Forgejo registry builds
This commit is contained in:
parent
091a9ee2f6
commit
8a093ee590
1 changed files with 43 additions and 22 deletions
|
|
@ -1,42 +1,63 @@
|
||||||
name: Build and Push
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOCKER_BUILDKIT: 1
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Login to Forgejo Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: git.mcintire.me
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
buildkitd-config-inline: |
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["docker-mirror.mcintire.me"]
|
||||||
|
|
||||||
- name: Generate image tags
|
- name: Log in to Docker Hub
|
||||||
id: tags
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Log in to container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.REGISTRY_URL }}
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
TIMESTAMP=$(date +%s)
|
TIMESTAMP=$(date +%s)
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||||
TAG="main-${TIMESTAMP}-${SHORT_SHA}"
|
IMAGE=${{ secrets.REGISTRY_URL }}/${{ github.repository }}
|
||||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
|
||||||
echo "Building image with tag: ${TAG}"
|
echo "tag=${IMAGE}:main-${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_OUTPUT
|
||||||
|
echo "latest_tag=${IMAGE}:latest" >> $GITHUB_OUTPUT
|
||||||
|
echo "cache_tag=${IMAGE}:buildcache" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
git.mcintire.me/graham/aprs.me:${{ steps.tags.outputs.tag }}
|
${{ steps.meta.outputs.tag }}
|
||||||
git.mcintire.me/graham/aprs.me:latest
|
${{ steps.meta.outputs.latest_tag }}
|
||||||
cache-from: type=registry,ref=git.mcintire.me/graham/aprs.me:latest
|
cache-from: type=registry,ref=${{ steps.meta.outputs.cache_tag }}
|
||||||
cache-to: type=inline
|
cache-to: type=registry,ref=${{ steps.meta.outputs.cache_tag }},mode=max
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue