|
| 1 | +name: Fetch core CAPI components manifest and embed in Turtles chart for air-gapped installations. |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "0 0 * * *" # Run every day at midnight (UTC) |
| 5 | + # allow running manually on demand |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + TURTLES_REF: "${{ github.ref_name }}" |
| 10 | + GH_TOKEN: "${{ secrets.GH_TOKEN }}" |
| 11 | + |
| 12 | +jobs: |
| 13 | + create-core-capi-turtles-pr: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 19 | + with: |
| 20 | + ref: "${{ env.TURTLES_REF }}" |
| 21 | + token: ${{ env.GH_TOKEN }} |
| 22 | + # Allow making git push request later on |
| 23 | + persist-credentials: true |
| 24 | + |
| 25 | + - name: Configure the committer |
| 26 | + run: | |
| 27 | + user_id=$(gh api "/users/$APP_USER" --jq .id) |
| 28 | + git config --global user.name "$APP_USER" |
| 29 | + git config --global user.email "${user_id}+${APP_USER}@users.noreply.github.com" |
| 30 | + env: |
| 31 | + GH_TOKEN: "${{ env.GH_TOKEN }}" |
| 32 | + APP_USER: "${{ github.actor }}" |
| 33 | + |
| 34 | + - name: Run script to fetch components manifest |
| 35 | + run: | |
| 36 | + CAPI_VERSION=$(curl -s "https://api.github.com/repos/rancher-sandbox/cluster-api/releases/latest" | jq -r ".tag_name") |
| 37 | + echo "CAPI_VERSION=${CAPI_VERSION}" >> $GITHUB_ENV |
| 38 | + BRANCH="fetch-core-capi-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" |
| 39 | + echo "BRANCH=${BRANCH}" >> $GITHUB_ENV |
| 40 | + git checkout -b "$BRANCH" "$TURTLES_REF" |
| 41 | + CAPI_VERSION=$CAPI_VERSION ./.github/scripts/fetch-core-capi.sh |
| 42 | + git add charts/rancher-turtles |
| 43 | + if git diff --cached --quiet; then |
| 44 | + echo "No changes detected" |
| 45 | + echo "SKIP_PUSH=true" >> $GITHUB_ENV |
| 46 | + else |
| 47 | + git commit -m "chore: embed core CAPI ${CAPI_VERSION} in Turtles chart" |
| 48 | + echo "SKIP_PUSH=false" >> $GITHUB_ENV |
| 49 | + fi |
| 50 | +
|
| 51 | + - name: Push and create pull request |
| 52 | + if: env.SKIP_PUSH == 'false' |
| 53 | + env: |
| 54 | + GH_TOKEN: "${{ env.GH_TOKEN }}" |
| 55 | + run: | |
| 56 | + git push origin "$BRANCH" |
| 57 | + body="This PR fetches core CAPI $CAPI_VERSION components manifest from release and embeds the template in the Turtles chart for a simplified air-gapped installation." |
| 58 | +
|
| 59 | + gh pr create \ |
| 60 | + --title "chore: embed core CAPI provider $CAPI_VERSION manifest in chart" \ |
| 61 | + --body "$body" \ |
| 62 | + --head "${{ github.repository_owner }}:$BRANCH" \ |
| 63 | + --base "$TURTLES_REF" \ |
| 64 | + --label "area/installation" \ |
| 65 | + --label "kind/ci" |
0 commit comments