Merge pull request #47 from GiganticMinecraft/renovate/alpine-3.x #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish cloudflared-with-auto-dns-route docker image | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'image-definition/**' | |
- '.github/workflows/publish.yml' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
env: | |
image_name: cloudflared-with-auto-dns-route | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@master | |
with: | |
submodules: recursive | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: extract_cloudflared_image_tag | |
run: | | |
image_tag="$(grep -P -o "(?<=^FROM cloudflare/cloudflared\:)([0-9]+\.[0-9]+\.[0-9]+)" image-definition/Dockerfile)" | |
echo "::set-output name=image_tag::${image_tag}" | |
# Docker does not allow uppercase letters for image name, so we must replace repository_owner and so on | |
- id: prepare_image_id | |
name: Prepare image id's components | |
run: | | |
lowercase_id=ghcr.io/${{ github.repository_owner }}/${{ env.image_name }} | |
echo "::set-output name=lowercase_id::$(echo $lowercase_id | tr '[A-Z]' '[a-z]')" | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ steps.prepare_image_id.outputs.lowercase_id }} | |
tags: | | |
type=sha | |
type=raw,value=${{ steps.extract_cloudflared_image_tag.outputs.image_tag }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./image-definition | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |