-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: Publish ARC 2 | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: 'The branch, tag or SHA to cut a release from' | ||
required: false | ||
type: string | ||
default: '' | ||
release_tag_name: | ||
description: 'The name to tag the controller image with' | ||
required: true | ||
type: string | ||
default: 'canary' | ||
push_to_registries: | ||
description: 'Push images to registries' | ||
required: true | ||
type: boolean | ||
default: false | ||
publish_helm: | ||
description: 'Publish new helm chart' | ||
required: true | ||
type: boolean | ||
default: false | ||
|
||
env: | ||
HELM_VERSION: v3.8.0 | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
build-push-image: | ||
name: Build and push controller image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
# If inputs.ref is empty, it'll resolve to the default branch | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Resolve parameters | ||
id: resolve_parameters | ||
run: | | ||
echo "INFO: Resolving short SHA for ${{ inputs.ref }}" | ||
echo "short_sha=$(git rev-parse --short ${{ inputs.ref }})" >> $GITHUB_OUTPUT | ||
echo "INFO: Normalizing repository name (lowercase)" | ||
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
version: latest | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build & push controller image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
file: Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: VERSION=${{ inputs.release_tag_name }} | ||
push: ${{ inputs.push_to_registries }} | ||
tags: | | ||
ghcr.io/${{ steps.resolve_parameters.outputs.repository_owner }}/actions-runner-controller-2:${{ inputs.release_tag_name }} | ||
ghcr.io/${{ steps.resolve_parameters.outputs.repository_owner }}/actions-runner-controller-2:${{ inputs.release_tag_name }}-${{ steps.resolve_parameters.outputs.short_sha }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Job summary | ||
run: | | ||
echo "The [publish-arc2](https://github.com/actions/actions-runner-controller/blob/main/.github/workflows/publish-arc2.yaml) workflow run was completed successfully!" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "**Parameters:**" >> $GITHUB_STEP_SUMMARY | ||
echo "- Ref: ${{ inputs.ref }}" >> $GITHUB_STEP_SUMMARY | ||
echo "- Short SHA: ${{ steps.resolve_parameters.outputs.short_sha }}" >> $GITHUB_STEP_SUMMARY | ||
echo "- Release tag: ${{ inputs.release_tag_name }}" >> $GITHUB_STEP_SUMMARY | ||
echo "- Push to registries: ${{ inputs.push_to_registries }}" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
publish-helm-chart: | ||
if: ${{ inputs.publish_helm == true }} | ||
needs: build-push-image | ||
name: Publish Helm chart | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
# If inputs.ref is empty, it'll resolve to the default branch | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Resolve parameters | ||
id: resolve_parameters | ||
run: | | ||
echo "INFO: Resolving short SHA for ${{ inputs.ref }}" | ||
echo "short_sha=$(git rev-parse --short ${{ inputs.ref }})" >> $GITHUB_OUTPUT | ||
echo "INFO: Normalizing repository name (lowercase)" | ||
echo "repository_owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | ||
- name: Set up Helm | ||
uses: azure/setup-helm@v3.3 | ||
with: | ||
version: ${{ env.HELM_VERSION }} | ||
|
||
- name: Publish new helm chart | ||
run: | | ||
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin | ||
CHART_VERSION='$(cat charts_preview/actions-runner-controller-2/Chart.yaml | grep version: | cut -d " " -f 2)' | ||
echo "CHART_VERSION_TAG=${CHART_VERSION}-${{ steps.resolve_parameters.outputs.short_sha }}" >> $GITHUB_ENV | ||
helm package charts_preview/actions-runner-controller-2/ --version="${CHART_VERSION}-${{ steps.resolve_parameters.outputs.short_sha }}" | ||
# Tag is inferred from SemVer of Chart and cannot be set manually. | ||
# See https://helm.sh/docs/topics/registries/#the-push-subcommand | ||
helm push actions-runner-controller-"${CHART_VERSION}-${{ steps.resolve_parameters.outputs.short_sha }}".tgz oci://ghcr.io/${{ steps.resolve_parameters.outputs.repository_owner }}/actions-runner-controller-helm-chart-2 | ||
- name: Job summary | ||
run: | | ||
echo "New helm chart published successfully!" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "**Parameters:**" >> $GITHUB_STEP_SUMMARY | ||
echo "- Ref: ${{ inputs.ref }}" >> $GITHUB_STEP_SUMMARY | ||
echo "- Short SHA: ${{ steps.resolve_parameters.outputs.short_sha }}" >> $GITHUB_STEP_SUMMARY | ||
echo "- Chart version: ${{ env.CHART_VERSION_TAG }}" >> $GITHUB_STEP_SUMMARY |