Browse Source

Workflows updates to manually merge changeset PRs and control those changes

a8trejo 1 year ago
parent
commit
c9e07cca58

+ 6 - 1
.changeset/changelog-config.js

@@ -3,16 +3,21 @@ const getReleaseLine = async (changeset) => {
     .split('\n')
     .map(l => l.trim())
     .filter(Boolean);
-  return `-   ${firstLine}`;
+  return `- ${firstLine}`;
 };
 
 const getDependencyReleaseLine = async () => {
   return '';
 };
 
+const getReleaseSummary = async (release) => {
+  return `## [${release.newVersion}]\n\n`;
+};
+
 const changelogFunctions = {
   getReleaseLine,
   getDependencyReleaseLine,
+  getReleaseSummary,
 };
 
 module.exports = changelogFunctions;

+ 3 - 2
.github/workflows/changeset-release.yml

@@ -1,5 +1,5 @@
 name: Changeset Release
-run-name: Changeset Release ${{ github.actor != 'R00-B0T' && '- Create PR' || '- Approve & Merge' }}
+run-name: Changeset Release ${{ github.actor != 'R00-B0T' && '- Create PR' || '- Ready for Review' }}
 
 on:
   pull_request:
@@ -84,6 +84,7 @@ jobs:
       
       # Auto-merge PR
       - name: Automerge on PR
-        run: gh pr merge --merge ${{ github.event.pull_request.number }}
+        if: false # Needs enablePullRequestAutoMerge in repo settings to work
+        run: gh pr merge --auto --merge ${{ github.event.pull_request.number }}
         env:
           GH_TOKEN: ${{ secrets.CROSS_REPO_ACCESS_TOKEN }}

+ 15 - 5
.github/workflows/marketplace-publish.yml

@@ -1,16 +1,26 @@
 name: Publish Extension
 on:
-  push:
-    branches: ["main"]
+  pull_request:
+    types: [closed]
   workflow_dispatch:
 
+env:
+  GIT_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }}
+
 jobs:
   publish-extension:
     runs-on: ubuntu-latest
-    if: ${{ github.actor == 'R00-B0T' || github.event_name == 'workflow_dispatch' }}
+    if: >
+        ( github.event_name == 'pull_request' &&
+        github.event.pull_request.base.ref == 'main' &&
+        contains(github.event.pull_request.title, 'Changeset version bump') ) ||
+        github.event_name == 'workflow_dispatch'
     steps:
-      - uses: actions/checkout@v3
-      - uses: actions/setup-node@v3
+      - uses: actions/checkout@v4
+        with:
+          ref: ${{ env.GIT_REF }}
+
+      - uses: actions/setup-node@v4
         with:
           node-version: 18
       - run: |