mirror of
https://github.com/przeprogramowani/10x-cli.git
synced 2026-09-19 03:30:01 +08:00
69 lines
2.6 KiB
YAML
69 lines
2.6 KiB
YAML
name: Prepare CLI version
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, reopened, synchronize]
|
|
branches: [master]
|
|
push:
|
|
branches: [master]
|
|
workflow_run:
|
|
workflows: [CI]
|
|
types: [completed]
|
|
branches: [master]
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
jobs:
|
|
select:
|
|
if: github.event_name != 'workflow_run' || (github.event.workflow_run.event == 'workflow_dispatch' && github.event.workflow_run.conclusion == 'success')
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
prs: ${{ steps.select.outputs.prs }}
|
|
steps:
|
|
- uses: actions/github-script@v7
|
|
id: select
|
|
with:
|
|
script: |
|
|
const prs = context.payload.pull_request ? [context.payload.pull_request] : await github.paginate(github.rest.pulls.list, { ...context.repo, state: 'open', base: 'master', per_page: 100 });
|
|
if (prs.length > 100) throw new Error('Bounded PR reconciliation required');
|
|
core.setOutput('prs', JSON.stringify(prs.filter(pr => pr.head.repo?.full_name === process.env.GITHUB_REPOSITORY).map(pr => pr.number)));
|
|
prepare:
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
actions: read
|
|
name: Prepare version (#${{ matrix.pr }})
|
|
needs: select
|
|
if: needs.select.outputs.prs != '[]'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
pr: ${{ fromJSON(needs.select.outputs.prs) }}
|
|
concurrency:
|
|
group: prepare-version-${{ matrix.pr }}
|
|
cancel-in-progress: false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# pull_request_target uses the trusted base SHA. Never checkout PR code here.
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
|
|
with:
|
|
bun-version: '1.3.8'
|
|
- run: bun install --frozen-lockfile --ignore-scripts
|
|
- name: Calculate and conditionally update the same PR using Git objects only
|
|
run: node scripts/prepare-version.mjs
|
|
env:
|
|
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
VERSION_ACTIONS_READ_TOKEN: ${{ github.token }}
|
|
VERSION_PR_NUMBER: ${{ matrix.pr }}
|
|
VERSION_RECORD_DIR: ${{ runner.temp }}/version-records
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
|
with:
|
|
name: version-preparation-${{ matrix.pr }}-${{ github.run_id }}-${{ github.run_attempt }}
|
|
path: ${{ runner.temp }}/version-records/${{ matrix.pr }}/version-preparation.json
|
|
if-no-files-found: warn
|
|
retention-days: 90
|