Following best practices for closing accounts (#1187) #465
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync versions on PR merge | ||
on: | ||
push: | ||
branches: [master] | ||
permissions: | ||
id-token: write | ||
contents: write | ||
env: | ||
NODE_VERSION: 17.0.1 | ||
ANCHOR_VERSION: 0.26.0 | ||
SOLANA_VERSION_STABLE: 1.14.13 | ||
RUST_TOOLCHAIN: stable | ||
jobs: | ||
dump-context: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
get-pr-number: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
pull-number: ${{ steps.get-pr-for-commit.outputs.pull-number }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Get PR for push event HEAD commit | ||
uses: ./.github/actions/get-pr-for-commit | ||
id: get-pr-for-commit | ||
with: | ||
commit-sha: ${{ github.sha }} | ||
# alt: on version, publish comment or label and then parse here. | ||
get-changes-scope: | ||
if: ${{ jobs.get-pr-number.outputs.pull-number }} != -1 | ||
Check failure on line 42 in .github/workflows/publish-on-pr-merge.yml GitHub Actions / Sync versions on PR mergeInvalid workflow file
|
||
runs-on: ubuntu-latest | ||
outputs: | ||
changed-packages: ${{ steps.get-changed-package-scope.outputs.result }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# - name: Get PR for push event HEAD commit | ||
# uses: ./.github/actions/get-pr-for-commit | ||
# id: get-pr-for-commit | ||
# with: | ||
# commit-sha: ${{ github.sha }} | ||
- name: List changed files | ||
uses: ./.github/actions/list-changed-files | ||
id: list-changed-files | ||
with: | ||
pull-number: ${{ jobs.get-pr-number.outputs.pull-number }} | ||
# only include files which might contain version bumps | ||
include: '["package.json", "Cargo.toml"]' | ||
# map fetched changed files to package / lang (list) | ||
- name: Get scope of changed packages | ||
uses: actions/github-script@v4 | ||
id: get-changed-package-scope | ||
with: | ||
# update regexp to consider other subdirs - e.g. `rust|test|cli|<etc>` | ||
script: | | ||
const files = ${{ steps.list-changed-files.outputs.changed-files }} | ||
const regexp = /[a-zA-Z\-]+\/(js|program)/g | ||
const uniqueFilesObj = files.reduce((p, file) => { | ||
const match = file.match(regexp) | ||
if (match) { | ||
// use first match result | ||
if (!p[match[0]]) p[match[0]] = 1 | ||
} | ||
return p | ||
}, {}) | ||
return Array.from(Object.keys(uniqueFilesObj)) | ||
publish-version-changes: | ||
if: ${{ jobs.get-pr-number.outputs.pull-number }} != -1 | ||
needs: [get-changes-scope] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Publish version changes | ||
uses: ./.github/actions/publish-version-changes | ||
id: publish-version-changes | ||
with: | ||
changed-packages: ${{ needs.get-changes-scope.outputs.changed-packages }} | ||
cargo-token: ${{ secrets.CARGO_TOKEN }} | ||
npm-token: ${{ secrets.NPM_TOKEN }} |