Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions .github/workflows/merge-maintained-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
branches:
- "1.22.x"

# The merge is pushed with a phpstan-push App token from the push
# environment, not the workflow token; it stays authored by phpstan-bot.
permissions: {}

concurrency:
Expand All @@ -16,23 +18,37 @@
jobs:
merge:
name: Merge branch
if: github.repository_owner == 'phpstan'
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout to fetch the code; the merge is made with PHPSTAN_BOT_TOKEN
environment:
name: push
deployment: false
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit

- name: "Mint a push token for phpstan/phpdoc-parser"
id: push-token
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ vars.PUSH_APP_CLIENT_ID }}
private-key: ${{ secrets.PUSH_APP_PRIVATE_KEY }}
repositories: phpdoc-parser
permission-contents: write
# the merge may bring changes to .github/workflows
permission-workflows: write

- name: "Checkout"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # zizmor: ignore[artipacked] -- the persisted App token credentials push the merge below
with:
persist-credentials: false
fetch-depth: 0
ref: '1.23.x'
token: ${{ steps.push-token.outputs.token }}
- name: "Merge branch"
uses: everlytic/branch-merge@c4a244dc23143f824ae6c022a10732566cb8e973 # 1.1.5
with:
github_token: "${{ secrets.PHPSTAN_BOT_TOKEN }}"
source_ref: ${{ github.ref }}
target_branch: '1.23.x'
commit_message_template: 'Merge branch {source_ref} into {target_branch}'
run: |
git config --global user.name "phpstan-bot"
git config --global user.email "ondrej+phpstanbot@mirtes.cz"
git merge --strategy=ort "origin/${GITHUB_REF_NAME}" -m "Merge branch ${GITHUB_REF_NAME} into 1.23.x"
git push
9 changes: 6 additions & 3 deletions .github/workflows/send-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types: [published]

# GITHUB_TOKEN needs no permissions: phpstan-src is checked out and the pull request
# is sent with PHPSTAN_BOT_TOKEN.
# is sent with PHPSTAN_BOT_PULL_REQUESTS_TOKEN from the bot-pr environment.
permissions: {}

concurrency:
Expand All @@ -18,6 +18,9 @@ jobs:
send-pr:
name: "Send pull request"
runs-on: "ubuntu-latest"
environment:
name: bot-pr
deployment: false
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
Expand All @@ -36,7 +39,7 @@ jobs:
persist-credentials: false
repository: phpstan/phpstan-src
path: phpstan-src
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}
token: ${{ secrets.PHPSTAN_BOT_PULL_REQUESTS_TOKEN }}
ref: 2.3.x

- name: "Install dependencies"
Expand All @@ -55,7 +58,7 @@ jobs:
id: create-pr
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
with:
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}
token: ${{ secrets.PHPSTAN_BOT_PULL_REQUESTS_TOKEN }}
path: ./phpstan-src
branch-suffix: random
delete-branch: true
Expand Down
8 changes: 4 additions & 4 deletions .github/zizmor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
rules:
secrets-outside-env:
config:
# These are repository secrets used by the release workflows (create-tag, release,
# send-pr, merge-maintained-branch, release-toot, release-tweet). Moving them into
# dedicated environments has to be done in the repository settings first.
# Repository-level secrets used by release automation (create-tag, release, release-toot,
# release-tweet); they are not scoped to deployment environments.
allow:
- PHPSTAN_BOT_TOKEN
- PHPSTAN_BOT_CONTENTS_TOKEN
- RELEASE_DISPATCH_TOKEN
- MASTODON_ACCESS_TOKEN
- TWITTER_CONSUMER_API_KEY
- TWITTER_CONSUMER_API_SECRET
Expand Down
Loading