Workflow file for this run
This file contains hidden or 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 and Release Extensions | |
on: | |
release: | |
types: [released] | |
push: | |
branches: | |
- main | |
paths: | |
- manifest.json | |
env: | |
ACTIONS_RUNNER_DEBUG: false | |
CI_COMMIT_MESSAGE: CI Build Artifacts | |
GH_TOKEN: ${{ github.token }} | |
jobs: | |
sync: | |
if: github.repository_owner == 'rancher' && github.ref_type != 'tag' | |
name: Sync and Release Extensions | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure Git | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Setup Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.12.1 | |
- name: Run sync script | |
shell: bash | |
id: sync_script | |
run: | | |
chmod +x ./scripts/sync-charts | |
./scripts/sync-charts | |
- name: Generate branch name based on date and time | |
run: echo "NOW=$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_ENV | |
- name: Commit Changes and push to a branch | |
run: | | |
git checkout -b sync-${{ env.NOW }} | |
git add ./{assets,charts,extensions,icons,index.yaml} | |
git commit -a -m "Sync extensions ${{ env.NOW }}" | |
git push origin sync-${{ env.NOW }} | |
- name: Create Pull Request | |
run: | | |
# Create the PR using the GitHub CLI | |
pr_number=$(gh pr create \ | |
--title "Create PR for extension sync: ${{ env.NOW }}" \ | |
--body "This PR was automatically created by a GitHub Action." \ | |
--base main \ | |
--head sync-${{ env.NOW }} \ | |
--fill \ | |
--repo ${{ github.repository }} | awk '{print $NF}') # Get the PR URL and Extract the last element (the PR number) | |
# Check if pr_number is empty (creation failed) | |
if [ -z "$pr_number" ]; then | |
echo "Failed to create PR." | |
exit 1 | |
fi | |
# Store the PR number as an output | |
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV | |
- name: Merge Pull Request when approved | |
run: | | |
# Merge the PR using the GitHub CLI | |
gh pr merge ${{ env.PR_NUMBER }} --delete-branch --merge --repo ${{ github.repository }} | |
- name: Run chart-releaser | |
uses: helm/[email protected] | |
with: | |
charts_dir: ./charts/* | |
env: | |
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
CR_SKIP_EXISTING: true | |
sync-catalogs: | |
if: github.repository_owner == 'rancher' && github.ref_type == 'tag' | |
name: Sync and Release Extension Catalog | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure Git | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Login to Container Registry | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Sync Catalog Image with Registry | |
id: sync_catalog_script | |
run: | | |
chmod +x ./scripts/bundle-catalog | |
./scripts/bundle-catalog -t ${{ github.ref_name }} |