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:
|
||||
push:
|
||||
branches: [main]
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
DOCKER_BUILDKIT: 1
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Forgejo Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.mcintire.me
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
buildkitd-config-inline: |
|
||||
[registry."docker.io"]
|
||||
mirrors = ["docker-mirror.mcintire.me"]
|
||||
|
||||
- name: Generate image tags
|
||||
id: tags
|
||||
- name: Log in to Docker Hub
|
||||
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: |
|
||||
TIMESTAMP=$(date +%s)
|
||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||
TAG="main-${TIMESTAMP}-${SHORT_SHA}"
|
||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||
echo "Building image with tag: ${TAG}"
|
||||
IMAGE=${{ secrets.REGISTRY_URL }}/${{ github.repository }}
|
||||
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
|
||||
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
|
||||
uses: docker/build-push-action@v5
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
git.mcintire.me/graham/aprs.me:${{ steps.tags.outputs.tag }}
|
||||
git.mcintire.me/graham/aprs.me:latest
|
||||
cache-from: type=registry,ref=git.mcintire.me/graham/aprs.me:latest
|
||||
cache-to: type=inline
|
||||
${{ steps.meta.outputs.tag }}
|
||||
${{ steps.meta.outputs.latest_tag }}
|
||||
cache-from: type=registry,ref=${{ steps.meta.outputs.cache_tag }}
|
||||
cache-to: type=registry,ref=${{ steps.meta.outputs.cache_tag }},mode=max
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue