sync-extensions.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. name: Sync and Release Extensions
  2. on:
  3. push:
  4. branches:
  5. - main
  6. paths:
  7. - manifest.json
  8. env:
  9. ACTIONS_RUNNER_DEBUG: false
  10. CI_COMMIT_MESSAGE: CI Build Artifacts
  11. GH_TOKEN: ${{ github.token }}
  12. jobs:
  13. sync:
  14. if: github.repository_owner == 'rancher'
  15. name: Sync and Release Extensions
  16. runs-on: ubuntu-latest
  17. permissions: write-all
  18. steps:
  19. - name: Checkout
  20. uses: actions/checkout@v3
  21. - name: Configure Git
  22. run: |
  23. git config user.name github-actions
  24. git config user.email github-actions@github.com
  25. - name: Setup Helm
  26. uses: azure/setup-helm@v3
  27. with:
  28. version: v3.12.1
  29. - name: Run sync script
  30. shell: bash
  31. id: sync_script
  32. run: |
  33. chmod +x ./scripts/sync
  34. ./scripts/sync
  35. - name: Commit Changes
  36. run: |
  37. git add ./{assets,charts,extensions,icons,index.yaml}
  38. git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}"
  39. - name: Create Pull Request
  40. run: |
  41. # Create the PR using the GitHub CLI
  42. pr_number=$(gh pr create \
  43. --title "Create PR for extension sync: ${{ env.CI_COMMIT_MESSAGE }}" \
  44. --body "This PR was automatically created by a GitHub Action." \
  45. --base main \
  46. --head ${{ github.ref_name }} \
  47. --fill \
  48. --repo ${{ github.repository }} | awk '{print $NF}') # Get the PR URL and Extract the last element (the PR number)
  49. # Check if pr_number is empty (creation failed)
  50. if [ -z "$pr_number" ]; then
  51. echo "Failed to create PR."
  52. exit 1
  53. fi
  54. # Store the PR number as an output
  55. echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
  56. - name: Run chart-releaser
  57. uses: helm/chart-releaser-action@v1.5.0
  58. with:
  59. charts_dir: ./charts/*
  60. env:
  61. CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
  62. CR_SKIP_EXISTING: true
  63. merge-pr:
  64. needs: sync
  65. runs-on: ubuntu-latest
  66. steps:
  67. - name: Merge Pull Request
  68. run: |
  69. # Merge the PR using the GitHub CLI
  70. gh pr merge ${{ needs.create-pr.outputs.pr_number }} --merge --repo ${{ github.repository }}
  71. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}