Skip to content

Commit e84fb9b

Browse files
authored
Merge pull request #35 from php-fast-forward/github-actions
[ci] Fix GitHub Actions workflow caching and auto-assign/label-sync configuration (#36)
2 parents bda2f6d + 6c039dd commit e84fb9b

File tree

7 files changed

+127
-25
lines changed

7 files changed

+127
-25
lines changed

.github/workflows/auto-assign.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Auto assign PR author
2+
3+
on:
4+
issues:
5+
types: [ opened, reopened ]
6+
pull_request_target:
7+
types: [ opened, reopened, synchronize ]
8+
workflow_call:
9+
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
14+
jobs:
15+
assign-author:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Auto assign PR author
19+
uses: toshimaru/auto-author-assign@v3.0.1
20+
with:
21+
repo-token: ${{ github.token }}

.github/workflows/label-sync.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Pull Request Label Sync
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, synchronize]
6+
pull_request:
7+
types: [opened, reopened, synchronize]
8+
workflow_call:
9+
inputs:
10+
copy_issue_labels:
11+
type: boolean
12+
default: true
13+
description: "Copy labels from linked issue"
14+
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
19+
jobs:
20+
copy-issue-labels:
21+
if: inputs.copy_issue_labels == true || github.event_name != 'workflow_call'
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v6
26+
27+
- name: Extract issue number from PR
28+
id: extract-issue
29+
env:
30+
BODY: ${{ github.event.pull_request.body }}
31+
TITLE: ${{ github.event.pull_request.title }}
32+
run: |
33+
ISSUE=$(echo "$TITLE $BODY" | \
34+
grep -oiE '(closes|fixes|resolves|addresses)\s+#[[:digit:]]+' | \
35+
grep -oE '#[[:digit:]]+' | head -1 | tr -d '#')
36+
37+
if [ -n "$ISSUE" ]; then
38+
echo "issue_number=$ISSUE" >> "$GITHUB_OUTPUT"
39+
fi
40+
41+
- name: Copy labels from issue to PR
42+
if: steps.extract-issue.outputs.issue_number != ''
43+
run: |
44+
LABELS=$(gh issue view "$ISSUE_NUM" --repo "$REPO" --json labels --jq '.labels[].name')
45+
46+
for label in $LABELS; do
47+
gh pr edit "$PR_NUM" --repo "$REPO" --add-label "$label" 2>/dev/null || true
48+
done
49+
env:
50+
ISSUE_NUM: ${{ steps.extract-issue.outputs.issue_number }}
51+
PR_NUM: ${{ github.event.pull_request.number }}
52+
REPO: ${{ github.repository }}
53+
GH_TOKEN: ${{ github.token }}

.github/workflows/reports.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,23 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v6
2424

25-
- name: Get Composer Cache Directory
26-
id: composer-cache
27-
run: |
28-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
29-
3025
- name: Cache Composer dependencies
3126
uses: actions/cache@v5
3227
with:
33-
path: ${{ steps.composer-cache.outputs.dir }}
34-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
35-
restore-keys: |
36-
${{ runner.os }}-composer-
28+
path: /tmp/composer-cache
29+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-composer-
3732
3833
- name: Install dependencies
3934
uses: php-actions/composer@v6
4035
env:
4136
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
37+
COMPOSER_CACHE_DIR: /tmp/composer-cache
4238
with:
4339
php_version: '8.3'
40+
command: 'install'
41+
args: '--prefer-dist --no-progress --no-interaction --no-plugins --no-scripts'
4442

4543
- name: Generate reports
4644
uses: php-actions/composer@v6

.github/workflows/tests.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,29 @@ jobs:
3838
steps:
3939
- uses: actions/checkout@v6
4040

41-
- name: Get Composer Cache Directory
42-
id: composer-cache
43-
run: |
44-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
45-
4641
- name: Cache Composer dependencies
4742
uses: actions/cache@v5
4843
with:
49-
path: ${{ steps.composer-cache.outputs.dir }}
50-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
51-
restore-keys: |
52-
${{ runner.os }}-composer-
44+
path: /tmp/composer-cache
45+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46+
restore-keys: |
47+
${{ runner.os }}-composer-
5348
5449
- name: Install dependencies
5550
uses: php-actions/composer@v6
5651
env:
5752
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
53+
COMPOSER_CACHE_DIR: /tmp/composer-cache
54+
with:
55+
php_version: ${{ matrix.php-version }}
56+
command: 'install'
57+
args: '--prefer-dist --no-progress --no-interaction --no-plugins --no-scripts'
58+
59+
- name: Composer Audit
60+
uses: php-actions/composer@v6
5861
with:
5962
php_version: ${{ matrix.php-version }}
63+
command: 'audit'
6064

6165
- name: Resolve minimum coverage
6266
id: minimum-coverage

.github/workflows/wiki.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,23 @@ jobs:
2626
submodules: recursive
2727
fetch-depth: 0
2828

29-
- name: Get Composer Cache Directory
30-
id: composer-cache
31-
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
32-
3329
- name: Cache Composer dependencies
3430
uses: actions/cache@v5
3531
with:
36-
path: ${{ steps.composer-cache.outputs.dir }}
37-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
32+
path: /tmp/composer-cache
33+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
3834
restore-keys: |
3935
${{ runner.os }}-composer-
4036
4137
- name: Install dependencies
4238
uses: php-actions/composer@v6
4339
env:
4440
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
41+
COMPOSER_CACHE_DIR: /tmp/composer-cache
4542
with:
4643
php_version: '8.3'
44+
command: 'install'
45+
args: '--prefer-dist --no-progress --no-interaction --no-plugins --no-scripts'
4746

4847
- name: Create Docs Markdown
4948
uses: php-actions/composer@v6
@@ -80,4 +79,4 @@ jobs:
8079
message: "Update wiki submodule pointer"
8180
default_author: github_actions
8281
pull: "--rebase --autostash"
83-
push: true
82+
push: true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Auto assign
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, synchronize]
6+
issues:
7+
types: [opened, reopened]
8+
9+
jobs:
10+
auto-assign:
11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
uses: php-fast-forward/dev-tools/.github/workflows/auto-assign.yml@main
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Label sync
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, synchronize]
6+
issues:
7+
types: [opened, reopened]
8+
9+
jobs:
10+
label-sync:
11+
permissions:
12+
pull-requests: write
13+
uses: php-fast-forward/dev-tools/.github/workflows/label-sync.yml@main

0 commit comments

Comments
 (0)