Release Fleet against test Rancher charts repo #123
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 Fleet against test Rancher charts repo | ||
on: | ||
schedule: | ||
# Run everyday at 1:00 PM | ||
- cron: '0 13 * * *' | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: "Branch to use for GitHub action workflow" | ||
required: true | ||
default: "main" | ||
charts_base_branch: | ||
description: "Use the following rancher/charts branch as a base (e.g. dev-v2.7)" | ||
required: true | ||
default: "dev-v2.9" | ||
charts_repo: | ||
description: "Push to the following Rancher charts repo (which must exist)" | ||
required: true | ||
default: "fleetrepoci/charts" | ||
charts_target_branch: | ||
description: "Use the following branch as a destination when pushing to the charts repo" | ||
env: | ||
GOARCH: amd64 | ||
permissions: | ||
contents: write | ||
jobs: | ||
push-test-rancher-charts: | ||
runs-on: runs-on,runner=8cpu-linux-x64,run-id=${{ github.run_id }} | ||
outputs: | ||
target_branch: ${{ steps.compute_target_branch.outputs.target_branch }} | ||
steps: | ||
- name: Set environment variables | ||
run: | | ||
tmp=${{github.event.inputs.ref}} | ||
ref=${tmp:-${{github.ref}}} | ||
tmp=${{github.event.inputs.charts_base_branch}} | ||
charts_base_branch=${tmp:-'dev-v2.8'} | ||
tmp=${{github.event.inputs.charts_repo}} | ||
charts_repo=${tmp:-fleetrepoci/charts} | ||
echo "ref=$ref" >> "$GITHUB_ENV" | ||
echo "charts_base_branch=$charts_base_branch" >> "$GITHUB_ENV" | ||
echo "charts_repo=$charts_repo" >> "$GITHUB_ENV" | ||
- name: Checkout rancher/fleet | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{github.event.inputs.ref}} | ||
path: fleet | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'fleet/go.mod' | ||
check-latest: true | ||
- name: Build fleet binaries | ||
run: | | ||
cd ./fleet | ||
./.github/scripts/build-fleet-binaries.sh | ||
cd - | ||
- name: Get UUID | ||
id: uuid | ||
run: echo "uuid=$(uuidgen)" >> $GITHUB_OUTPUT | ||
- name: Extract metadata for Fleet controller image | ||
id: meta-fleet | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ttl.sh/rancher-fleet-${{ steps.uuid.outputs.uuid }} | ||
tags: type=raw,value=1h | ||
- name: Build and push Fleet controller image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ./fleet | ||
file: ./fleet/package/Dockerfile | ||
build-args: | | ||
ARCH=${{ env.GOARCH }} | ||
push: true | ||
tags: ${{ steps.meta-fleet.outputs.tags }} | ||
labels: ${{ steps.meta-fleet.outputs.labels }} | ||
- name: Extract metadata for Fleet agent image | ||
id: meta-fleet-agent | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ttl.sh/rancher-fleet-agent-${{ steps.uuid.outputs.uuid }} | ||
tags: type=raw,value=1h | ||
- name: Build and push Fleet agent image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ./fleet | ||
file: ./fleet/package/Dockerfile.agent | ||
build-args: | | ||
ARCH=${{ env.GOARCH }} | ||
push: true | ||
tags: ${{ steps.meta-fleet-agent.outputs.tags }} | ||
labels: ${{ steps.meta-fleet-agent.outputs.labels }} | ||
- name: Checkout test charts repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{secrets.CI_PUSH_TO_FLEETREPOCI}} | ||
repository: ${{ env.charts_repo }} | ||
path: charts | ||
- name: Compute target branch name | ||
id: compute_target_branch | ||
run: | | ||
target_branch_name=${{github.event.inputs.charts_target_branch}} | ||
if [ ${{github.event_name}} = 'pull_request' ]; then | ||
target_branch_name=${{github.event.pull_request.head.ref}} | ||
elif [ -z ${{github.event.inputs.charts_target_branch}} ]; then | ||
target_branch_name=${{env.charts_base_branch}}-$(date +%Y%m%d%H%M%S) | ||
fi | ||
# Append prefix if not present | ||
prefix='fleetci-' | ||
if [ "${target_branch_name/$prefix/}" = $target_branch_name ]; then | ||
target_branch_name=$prefix$target_branch_name | ||
fi | ||
echo "target_branch=$target_branch_name" >> "$GITHUB_ENV" | ||
echo "target_branch=$target_branch_name" >> "$GITHUB_OUTPUT" | ||
- name: Set up test charts repo with latest upstream state | ||
run: | | ||
cd charts | ||
# Add upstream remote and fetch from it | ||
git remote add -f upstream https://github.com/rancher/charts | ||
git checkout -b $target_branch upstream/${{env.charts_base_branch}} | ||
if [ $? -eq 128 ]; then # branch already exists | ||
git checkout $target_branch | ||
git rebase upstream/${{env.charts_base_branch}} | ||
fi | ||
- name: Install dependencies | ||
run: sudo snap install yq --channel=v4/stable | ||
- name: Run release script | ||
run: | | ||
fleet_version=9.9.9 | ||
prev_chart=$(ls -1 ./charts/charts/fleet | tail -n 1) | ||
prev_fleet=${prev_chart#*+up} | ||
prev_chart=${prev_chart/+*} | ||
./fleet/.github/scripts/release-against-test-charts.sh \ | ||
$prev_fleet \ | ||
$fleet_version \ | ||
$prev_chart \ | ||
999.9.9 \ | ||
${{ steps.uuid.outputs.uuid }} | ||
- name: Push to custom branch | ||
run: | | ||
cd charts | ||
git push -u origin $target_branch | ||
test-fleet-in-rancher: | ||
uses: ./.github/workflows/e2e-test-fleet-in-rancher.yml | ||
needs: push-test-rancher-charts | ||
with: | ||
ref: ${{ github.ref }} | ||
charts_repo: ${{ env.charts_repo }} | ||
Check failure on line 179 in .github/workflows/release-against-test-charts.yml GitHub Actions / Release Fleet against test Rancher charts repoInvalid workflow file
|
||
charts_branch: ${{ needs.push-test-rancher-charts.outputs.target_branch }} | ||
fleet_version: 999.9.9+up9.9.9 |