Sfoglia il codice sorgente

Use a PR for changes

Neil MacDougall 2 mesi fa
parent
commit
ee42eddb09
2 ha cambiato i file con 32 aggiunte e 3 eliminazioni
  1. 31 2
      .github/workflows/sync-extensions.yml
  2. 1 1
      manifest.json

+ 31 - 2
.github/workflows/sync-extensions.yml

@@ -38,11 +38,30 @@ jobs:
           chmod +x ./scripts/sync
           ./scripts/sync
 
-      - name: Commit build
+      - name: Commit Changes
         run: |
           git add ./{assets,charts,extensions,icons,index.yaml}
           git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}"
-          git push
+
+      - name: Create Pull Request
+        run: |
+          # Create the PR using the GitHub CLI
+          pr_number=$(gh pr create \
+            --title "Create PR for extension sync: ${{ env.CI_COMMIT_MESSAGE }}" \
+            --body "This PR was automatically created by a GitHub Action." \
+            --base main \
+            --head ${{ github.ref_name }} \
+            --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_OUTPUT
 
       - name: Run chart-releaser
         uses: helm/chart-releaser-action@v1.5.0
@@ -51,3 +70,13 @@ jobs:
         env:
           CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
           CR_SKIP_EXISTING: true
+
+  merge-pr:
+    needs: sync
+    runs-on: ubuntu-latest
+    steps:
+      - name: Merge Pull Request
+        run: |
+          # Merge the PR using the GitHub CLI
+          gh pr merge ${{ needs.create-pr.outputs.pr_number }} --merge --repo ${{ github.repository }}
+    if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

+ 1 - 1
manifest.json

@@ -1,5 +1,5 @@
 {
-  "trigger": 1,
+  "trigger": 2,
   "extensions": {
     "cloud-casa-extension": {
       "repo": "catalogicsoftware/cloudcasa-rancher-extension",