fix spark-rbac (#1986) #151
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 Charts | |
on: | |
push: | |
branches: | |
- master | |
env: | |
REGISTRY_IMAGE: docker.io/kubeflow/spark-operator | |
jobs: | |
build-skip-check: | |
runs-on: ubuntu-latest | |
outputs: | |
skip: ${{ steps.skip-check.outputs.skip }} | |
version: ${{ steps.skip-check.outputs.VERSION_TAG }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check if build should be skipped | |
id: skip-check | |
run: | | |
VERSION_TAG=$(cat charts/spark-operator-chart/Chart.yaml | grep "appVersion: .*" | cut -c13-) | |
if git rev-parse -q --verify "refs/tags/$VERSION_TAG"; then | |
echo "Spark-Operator Docker Image Tag $VERSION_TAG already exists!" | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
else | |
git tag $VERSION_TAG | |
git push origin $VERSION_TAG | |
echo "Spark-Operator Docker Image new tag: $VERSION_TAG released" | |
echo "skip=false" >> "$GITHUB_OUTPUT" | |
fi | |
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT" | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- build-skip-check | |
if: needs.build-skip-check.outputs.skip == 'false' | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
echo "SCOPE=${platform//\//-}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
timeout-minutes: 1 | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
with: | |
version: v3.14.3 | |
- name: Login to Packages Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Spark-Operator Docker Image to Docker Hub | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
cache-to: type=gha,mode=max,scope=${{ env.SCOPE }} | |
cache-from: type=gha,scope=${{ env.SCOPE }} | |
push: true | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
publish-image: | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
- build-skip-check | |
if: needs.build-skip-check.outputs.skip == 'false' | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: digests-* | |
path: /tmp/digests | |
merge-multiple: true | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
tags: ${{ needs.build-skip-check.outputs.version }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
publish-chart: | |
runs-on: ubuntu-latest | |
if: needs.publish-image.result == 'success' || needs.publish-image.result == 'skipped' | |
needs: | |
- publish-image | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
- name: Release Spark-Operator Helm Chart | |
uses: helm/[email protected] | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_RELEASE_NAME_TEMPLATE: "spark-operator-chart-{{ .Version }}" |