-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #571 from mallardduck/backport/3/sync-ci-changes
[Backport release/v3.0] Various CI changes
- Loading branch information
Showing
8 changed files
with
193 additions
and
33 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"group:allNonMajor" | ||
], | ||
"baseBranches": [ | ||
"main", | ||
"release/v3.0", | ||
"release/v4.0", | ||
"release/v5.0" | ||
|
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,49 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
set -e | ||
|
||
# Function to get the previous tag | ||
getPreviousTag() { | ||
local tagPrefix="$1" | ||
# List all tags and filter ones that start with tagPrefix, sort by creation date | ||
git tag --sort=-creatordate | grep "^${tagPrefix}" | head -n 1 | ||
} | ||
|
||
# Determine if we're in a GitHub Actions environment | ||
if [ -n "$GITHUB_REF" ] && [ -n "$GITHUB_SHA" ]; then | ||
# Use GHA environment variables | ||
ref="$GITHUB_REF" | ||
commitSha="${GITHUB_SHA:0:7}" | ||
else | ||
# Fallback to local Git repo | ||
if [ ! -d ".git" ]; then | ||
echo "This script must be run from the root of a Git repository or GitHub Actions." | ||
exit 1 | ||
fi | ||
ref=$(git symbolic-ref HEAD) | ||
commitSha=$(git rev-parse --short HEAD) | ||
fi | ||
|
||
branchTag="" | ||
branchStaticTag="" | ||
prevTag="" | ||
|
||
if [ "$ref" == "refs/heads/main" ]; then | ||
branchTag="head" | ||
branchStaticTag="main-${commitSha}" | ||
prevTag=$(getPreviousTag "main-") | ||
elif [[ "$ref" == refs/heads/release/* ]]; then | ||
version="${ref#refs/heads/release/}" # Extract "vX.0" | ||
branchTag="${version}-head" | ||
branchStaticTag="${version}-head-${commitSha}" | ||
prevTag=$(getPreviousTag "${version}-head-") | ||
else | ||
echo "Unsupported branch pattern. Expected 'main' or 'release/*'." | ||
exit 1 | ||
fi | ||
|
||
# Output the results | ||
echo "branch_tag=${branchTag}" | ||
echo "branch_static_tag=${branchStaticTag}" | ||
echo "prev_static_tag=${prevTag}" |
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
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,81 @@ | ||
name : Branch head Prerelease Images | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/v[0-9]+.0 | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
REGISTRY: docker.io | ||
REPO : rancher | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
prebuild-env: | ||
name: Prebuild needed Env vars | ||
runs-on : runs-on,image=ubuntu22-full-x64,runner=4cpu-linux-x64,run-id=${{ github.run_id }} | ||
steps: | ||
- name: Check out the repository to the runner | ||
uses: actions/checkout@v4 | ||
- name: Set Branch Tag and Other Variables | ||
id: set-vars | ||
run: bash ./.github/scripts/branch-tags.sh >> $GITHUB_OUTPUT | ||
outputs: | ||
branch_tag: ${{ steps.set-vars.outputs.branch_tag }} | ||
branch_static_tag: ${{ steps.set-vars.outputs.branch_static_tag }} | ||
prev_tag: ${{ steps.set-vars.outputs.prev_tag }} | ||
push: | ||
needs : [ | ||
prebuild-env, | ||
] | ||
permissions: | ||
contents : read | ||
id-token: write | ||
name : Build and push BRO images | ||
runs-on : runs-on,image=ubuntu22-full-x64,runner=4cpu-linux-x64,run-id=${{ github.run_id }} | ||
steps: | ||
- name : "Read vault secrets" | ||
uses : rancher-eio/read-vault-secrets@main | ||
if: ${{ github.repository_owner == 'rancher' }} | ||
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 : Checkout repository | ||
uses: actions/checkout@v4 | ||
- 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: ${{ env.DOCKER_USERNAME || vars.REPO }} | ||
password: ${{ env.DOCKER_PASSWORD || secrets.DOCKER_PW }} | ||
- name: Build and push BRO image | ||
env: | ||
FULL_IMAGE_URL: "${{ env.REGISTRY }}/${{ vars.REPO || env.REPO || github.repository_owner }}/backup-restore-operator" | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./package/Dockerfile | ||
build-args: | | ||
TAG=${{ needs.prebuild-env.outputs.branch_static_tag }} | ||
push: true | ||
tags: ${{ env.FULL_IMAGE_URL }}:${{ needs.prebuild-env.outputs.branch_static_tag }} | ||
platforms: linux/amd64,linux/arm64 | ||
- name: Update rolling tag to new static tag | ||
env: | ||
FULL_IMAGE_URL: ${{ env.REGISTRY }}/${{ vars.REPO || env.REPO || github.repository_owner }}/backup-restore-operator | ||
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 }}:${{ needs.prebuild-env.outputs.branch_static_tag }} ${{ env.FULL_IMAGE_URL }}:${{ needs.prebuild-env.outputs.branch_tag }} |
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
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
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
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