Skip to content

Merge pull request #31 from rancher/gha-portpr-12657722302-1 #6

Merge pull request #31 from rancher/gha-portpr-12657722302-1

Merge pull request #31 from rancher/gha-portpr-12657722302-1 #6

Workflow file for this run

name: Stable Image Releases
on:
push:
tags:
- '*'
# GitHub settings / example values:
#
# org level vars:
# - PUBLIC_REGISTRY: docker.io
# repo level vars:
# - PUBLIC_REGISTRY_REPO: rancher
# repo level secrets:
# - PUBLIC_REGISTRY_USERNAME
# - PUBLIC_REGISTRY_PASSWORD
permissions:
contents: write # Upload artefacts to release.
env:
PUBLIC_REGISTRY: docker.io
jobs:
publish-public:
permissions:
contents: read
# write is needed for:
# - OIDC for cosign's use in ecm-distro-tools/publish-image.
# - Read vault secrets in rancher-eio/read-vault-secrets.
id-token: write
packages: write
attestations: write
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Load Secrets from Vault
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ;
- name: Build and push all platforms
uses: rancher/ecm-distro-tools/actions/publish-image@master
with:
image: ${{ vars.IMAGE_NAME || 'kuberlr-kubectl' }}
tag: ${{ github.ref_name }}
platforms: "linux/amd64,linux/arm64"
public-registry: ${{ env.PUBLIC_REGISTRY }}
public-repo: ${{ vars.REPO || github.repository_owner }}
public-username: ${{ env.DOCKER_USERNAME || vars.DOCKER_USERNAME || github.repository_owner }}
public-password: ${{ env.DOCKER_PASSWORD || secrets.DOCKER_PASSWORD }}
push-to-prime: false
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Re-tag the image to ghcr.io/${{ github.repository_owner }}
env:
FULL_IMAGE_URL: ${{ env.PUBLIC_REGISTRY }}/${{ vars.REPO || github.repository_owner }}/${{ vars.IMAGE_NAME || 'kuberlr-kubectl' }}
FULL_IMAGE_GHCR_URL: ghcr.io/${{ github.repository_owner }}/${{ vars.IMAGE_NAME || 'kuberlr-kubectl' }}
run: |
VERSION="1.2.0"
curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz"
mkdir -p oras-install/
tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/
oras-install/oras copy ${{ env.FULL_IMAGE_URL }}:${{ github.ref_name }} ${{ env.FULL_IMAGE_GHCR_URL }}:${{ github.ref_name }}