mirror of
https://github.com/stakater/Reloader.git
synced 2026-02-14 18:09:50 +00:00
92 lines
2.4 KiB
YAML
92 lines
2.4 KiB
YAML
name: Push PR Image on Label
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
types: [ labeled ]
|
|
paths:
|
|
- '!.markdownlint.yaml'
|
|
- '!.vale.ini'
|
|
- '!Dockerfile-docs'
|
|
- '!docs-nginx.conf'
|
|
- '!docs/**'
|
|
- '!theme_common'
|
|
- '!theme_override'
|
|
- '!deployments/kubernetes/chart/reloader/**'
|
|
|
|
env:
|
|
DOCKER_FILE_PATH: Dockerfile
|
|
REGISTRY: ghcr.io
|
|
|
|
jobs:
|
|
|
|
build-and-push-pr-image:
|
|
permissions:
|
|
contents: read
|
|
|
|
runs-on: ubuntu-latest
|
|
name: Build and Push PR Image
|
|
if: ${{ github.event.label.name == 'build-and-push-pr-image' }}
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
ref: ${{github.event.pull_request.head.sha}}
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: 'go.mod'
|
|
check-latest: true
|
|
cache: true
|
|
|
|
- name: Install Dependencies
|
|
run: |
|
|
make install
|
|
|
|
- name: Run golangci-lint
|
|
run: make lint
|
|
|
|
- name: Generate Tags
|
|
id: generate_tag
|
|
run: |
|
|
sha=${{ github.event.pull_request.head.sha }}
|
|
tag="SNAPSHOT-PR-${{ github.event.pull_request.number }}-${sha:0:8}"
|
|
echo "GIT_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Generate image repository path for ghcr registry
|
|
run: |
|
|
echo GHCR_IMAGE_REPOSITORY=${{env.REGISTRY}}/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
|
|
|
- name: Login to ghcr registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{env.REGISTRY}}
|
|
username: stakater-user
|
|
password: ${{secrets.GITHUB_TOKEN}}
|
|
|
|
- name: Build Docker Image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ${{ env.DOCKER_FILE_PATH }}
|
|
pull: true
|
|
push: true
|
|
build-args: BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }}
|
|
cache-to: type=inline
|
|
platforms: linux/amd64,linux/arm,linux/arm64
|
|
tags: |
|
|
${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}
|
|
labels: |
|
|
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
|
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|