71 lines
2.2 KiB
YAML
71 lines
2.2 KiB
YAML
name: Build and Push Docker Image from External Repo
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 2 * * 0" # build periodically
|
|
workflow_dispatch:
|
|
inputs:
|
|
external_ref:
|
|
description: "Git ref (branch/tag/SHA) to build from in the external repo"
|
|
required: false
|
|
default: "master"
|
|
|
|
env:
|
|
EXTERNAL_REPO: "Wavyzz/cf-bypass-fast" # owner/name of the other repo (in the same Gitea)
|
|
DEFAULT_EXTERNAL_REF: "master" # default branch/tag/SHA to build
|
|
IMAGE_NAME: "cf-bypass-fast" # final image name (tag appended later)
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout this repo (for context & scripts, optional)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Checkout external repository to ./external-src
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ env.EXTERNAL_REPO }}
|
|
ref: ${{ github.event.inputs.external_ref || env.DEFAULT_EXTERNAL_REF }}
|
|
server-url: ${{ github.server_url }}
|
|
path: external-src
|
|
fetch-depth: 0
|
|
|
|
- name: Decide image tag
|
|
id: tag
|
|
shell: bash
|
|
run: |
|
|
if [[ -n "${{ github.event.inputs.image_tag }}" ]]; then
|
|
TAG="${{ github.event.inputs.image_tag }}"
|
|
else
|
|
TAG="latest"
|
|
fi
|
|
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Set up Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ secrets.DOCKER_REGISTRY_HOST }}
|
|
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
|
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
# Point to the external checkout dir
|
|
context: ./external-src
|
|
# If the Dockerfile isn't named 'Dockerfile' or isn't at repo root, set it explicitly:
|
|
# file: ./external-src/path/to/Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ secrets.DOCKER_REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
|
|
${{ secrets.DOCKER_REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} |