Bump docker/metadata-action from 5.3.0 to 5.4.0 (#29) #63
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 push cloudflare-ddns image | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
jobs: | |
buildx: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
if: | | |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || | |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') | |
steps: | |
- name: Checkout | |
if: ${{ github.event_name != 'pull_request_target' }} | |
uses: actions/checkout@v4 | |
- name: Checkout PR | |
if: ${{ github.event_name == 'pull_request_target' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@v3.2.0 | |
with: | |
cosign-release: main | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup buildx | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
with: | |
install: true | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3.0.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Determine Docker image tag | |
id: docker_image_tag | |
run: | | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
else | |
echo "tag=$GITHUB_SHA" >> $GITHUB_OUTPUT | |
fi | |
- name: Run Buildx | |
run: | | |
docker build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ${{ secrets.DOCKER_REPO }}:latest -t ${{ secrets.DOCKER_REPO }}:${{ steps.docker_image_tag.outputs.tag }} --push . | |
# new way | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: docker_meta | |
uses: docker/metadata-action@v5.4.0 | |
with: | |
images: ghcr.io/mirioeggmann/cloudflare-ddns | |
tags: type=sha,format=long | |
- name: Build and Push container images | |
uses: docker/build-push-action@v5 | |
id: build-and-push | |
with: | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
push: true | |
tags: ghcr.io/${{ github.repository }}:latest | |
#- name: Sign image with a key | |
# run: | | |
# cosign sign --yes --key env://COSIGN_PRIVATE_KEY "${TAGS}@${DIGEST}" | |
# env: | |
# TAGS: ${{ steps.docker_meta.outputs.tags }} | |
# COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | |
# COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} | |
# DIGEST: ${{ steps.build-and-push.outputs.digest }} | |
- name: Sign the images with GitHub OIDC Token | |
env: | |
DIGEST: ${{ steps.build-and-push.outputs.digest }} | |
TAGS: ${{ steps.docker_meta.outputs.tags }} | |
run: cosign sign --yes "${TAGS}@${DIGEST}" |