Sync with upstream ingress-nginx releases and cherry-pick Rancher-specific changes #42
Workflow file for this run
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: Sync with upstream ingress-nginx releases and cherry-pick Rancher-specific changes | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Runs daily at midnight | |
workflow_dispatch: | |
jobs: | |
create-branches: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
outputs: | |
new-release-branches: ${{ steps.create-release-branches.outputs.NEW_RELEASE_BRANCHES }} | |
steps: | |
# - name: Read App Secrets | |
# uses: rancher-eio/read-vault-secrets@main | |
# with: | |
# secrets: | | |
# secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ; | |
# secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY | |
# - name: Create App Token | |
# uses: actions/create-github-app-token@v1 | |
# id: app-token | |
# with: | |
# app-id: ${{ env.APP_ID }} | |
# private-key: ${{ env.PRIVATE_KEY }} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
path: 'rancher-ingress-nginx' | |
fetch-depth: 0 | |
fetch-tags: true | |
# token: ${{ steps.app-token.outputs.token }} | |
- name: Configure git user | |
run: | | |
echo "[INFO] Setting up git user in git repository." | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Fetch the new tags from kubernetes/ingress-nginx repository | |
run: | | |
cd rancher-ingress-nginx | |
$GITHUB_WORKSPACE/rancher-ingress-nginx/scripts/check-for-new-tag.sh | |
- name: Create new release branches in rancher/ingress-nginx | |
id: create-release-branches | |
run: | | |
cd rancher-ingress-nginx | |
$GITHUB_WORKSPACE/rancher-ingress-nginx/scripts/create-release-branch.sh | |
- name: Debug outputs | |
run: | | |
echo "NEW_RELEASE_BRANCHES: ${{ steps.create-release-branches.outputs.NEW_RELEASE_BRANCHES }}" | |
shell: bash | |
build-and-validate: | |
needs: create-branches | |
runs-on: runs-on,runner=4cpu-linux-x64,run-id=${{ github.run_id }} | |
if: ${{ needs.create-branches.outputs.new-release-branches != '[]' }} # Skip if no new branches | |
container: | |
image: rancher/dapper:v0.6.0 | |
permissions: | |
contents: write | |
id-token: write | |
strategy: | |
matrix: | |
branches: ${{ fromJSON(needs.create-branches.outputs.new-release-branches) }} | |
fail-fast: false | |
steps: | |
- name: Fix the not-a-git-repository issue | |
run: | | |
apk -U add git | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Read App Secrets | |
uses: rancher-eio/read-vault-secrets@main | |
with: | |
secrets: | | |
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ; | |
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY | |
- name: Create App Token | |
uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ env.APP_ID }} | |
private-key: ${{ env.PRIVATE_KEY }} | |
- name: Checkout repository with branch ${{ matrix.branches }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ matrix.branches }} | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: Validate with Dapper for ${{ matrix.branches }} | |
run: | | |
git checkout ${{ matrix.branches }} | |
dapper validate | |
- name: Build with Dapper for ${{ matrix.branches }} | |
run: | | |
git stash --all | |
dapper build | |
- name: Push release tag for ${{ matrix.branches }} | |
run: | | |
# To stash any changes created by dapper CI run | |
git stash --all | |
if ! $(git push --quiet --no-progress origin $RELEASE_BRANCH > /dev/null); then | |
echo "[ERROR] Failed while pushing the branch $RELEASE_BRANCH to rancher repository. Skipping the version $RELEASE_BRANCH." | |
exit 1 | |
else | |
echo "[INFO] Successfully pushed branch $RELEASE_BRANCH: https://github.com/rancher/ingress-nginx/tree/$RELEASE_BRANCH" | |
fi | |
# Remove the '-fix' suffix to create the tag name | |
TAG="${RELEASE_BRANCH%-fix*}" | |
TAG="$TAG-rancher1" | |
echo "[INFO] Creating the tag: $TAG for branch: $RELEASE_BRANCH" | |
# Create the tag | |
if ! git tag "$TAG" "$RELEASE_BRANCH"; then | |
echo "[ERROR] Failed while creating the tag $TAG in the repository." | |
exit 1 | |
fi | |
# Push the tag to origin | |
if ! git push origin "$TAG"; then | |
echo "[ERROR] Failed while pushing the tag $TAG to the repository." | |
exit 1 | |
else | |
echo "[INFO] Successfully pushed tag $TAG: https://github.com/rancher/ingress-nginx/releases/tag/$TAG" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
RELEASE_BRANCH: ${{ matrix.branches }} |