|
28 | 28 | - run: pnpm pack:zip |
29 | 29 | - run: pnpm pack:tgz |
30 | 30 | - run: pnpm -s marketplace:snippet > marketplace-index-snippet.json |
| 31 | + - id: marketplace-meta |
| 32 | + run: | |
| 33 | + node --input-type=module -e "import fs from 'fs'; const pkg = JSON.parse(fs.readFileSync('package.json','utf8')); const meta = JSON.parse(fs.readFileSync('napgram-plugin.json','utf8')); const id = (meta.id || pkg.name); console.log(`id=${id}`); console.log(`version=${pkg.version}`);" >> $GITHUB_OUTPUT |
| 34 | + - if: ${{ secrets.MARKETPLACE_PR_TOKEN != '' }} |
| 35 | + name: Ensure marketplace fork |
| 36 | + uses: actions/github-script@v7 |
| 37 | + with: |
| 38 | + github-token: ${{ secrets.MARKETPLACE_PR_TOKEN }} |
| 39 | + script: | |
| 40 | + const upstream = { owner: 'NapGram', repo: 'marketplace' }; |
| 41 | + const forkOwner = context.actor; |
| 42 | + try { |
| 43 | + await github.rest.repos.get({ owner: forkOwner, repo: upstream.repo }); |
| 44 | + return; |
| 45 | + } catch (error) { |
| 46 | + if (error.status !== 404) throw error; |
| 47 | + } |
| 48 | + await github.rest.repos.createFork({ owner: upstream.owner, repo: upstream.repo }); |
| 49 | + for (let i = 0; i < 10; i++) { |
| 50 | + try { |
| 51 | + await github.rest.repos.get({ owner: forkOwner, repo: upstream.repo }); |
| 52 | + return; |
| 53 | + } catch { |
| 54 | + await new Promise(resolve => setTimeout(resolve, 3000)); |
| 55 | + } |
| 56 | + } |
| 57 | + core.setFailed('marketplace fork not ready'); |
| 58 | + - if: ${{ secrets.MARKETPLACE_PR_TOKEN != '' }} |
| 59 | + uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + repository: ${{ github.actor }}/marketplace |
| 62 | + token: ${{ secrets.MARKETPLACE_PR_TOKEN }} |
| 63 | + path: marketplace |
| 64 | + - if: ${{ secrets.MARKETPLACE_PR_TOKEN != '' }} |
| 65 | + run: node scripts/marketplace-upsert.mjs --index marketplace/index.json --snippet marketplace-index-snippet.json |
| 66 | + - if: ${{ secrets.MARKETPLACE_PR_TOKEN != '' }} |
| 67 | + uses: peter-evans/create-pull-request@v6 |
| 68 | + with: |
| 69 | + token: ${{ secrets.MARKETPLACE_PR_TOKEN }} |
| 70 | + path: marketplace |
| 71 | + commit-message: "marketplace: update ${{ steps.marketplace-meta.outputs.id }} ${{ steps.marketplace-meta.outputs.version }}" |
| 72 | + branch: "marketplace/${{ steps.marketplace-meta.outputs.id }}-${{ steps.marketplace-meta.outputs.version }}" |
| 73 | + title: "marketplace: update ${{ steps.marketplace-meta.outputs.id }} ${{ steps.marketplace-meta.outputs.version }}" |
| 74 | + body: "Auto-generated marketplace submission." |
| 75 | + base: main |
| 76 | + push-to-fork: ${{ github.actor }}/marketplace |
31 | 77 | - uses: softprops/action-gh-release@v2 |
32 | 78 | with: |
33 | 79 | files: | |
|
0 commit comments