sync-extensions.yml 2.3 KB

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