uddate token and image #2
Workflow file for this run
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: Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
inputs: | |
image_tag: | |
description: Base Image Tag (before the :) | |
type: string | |
required: false | |
default: rancher/rancher-cleanup | |
jobs: | |
shellcheck: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run shellcheck | |
run: | | |
sudo apt install shellcheck | |
shellcheck -S warning *.sh | |
test-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build docker image | |
run: docker build -t ${{ github.repository_owner }}/rancher-cleanup:test . | |
release: | |
permissions: | |
id-token: write | |
contents: write | |
runs-on: ubuntu-latest | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
needs: | |
- shellcheck | |
- test-build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set IMAGE_TAG | |
run: | | |
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then | |
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
else | |
echo "IMAGE_TAG=${{ github.event.inputs.image_tag }}" >> $GITHUB_ENV | |
fi | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_PAT }} # Use a PAT instead of GITHUB_TOKEN | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=${{ env.IMAGE_TAG }} | |
type=raw,value=latest | |
- name: Echo image tags for debugging | |
run: | | |
echo "Tags: ${{ steps.meta.outputs.tags }}" | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
provenance: false |