Skip to content

Commit 31793bd

Browse files
authored
Merge pull request #846 from Adyen/fix/format-before-pr
feat(ci): move formatting step before PR creation
2 parents aa6573b + 899384b commit 31793bd

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

.github/actions/format/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'Format PHP Code'
2+
description: 'Runs composer run fmt'
3+
inputs:
4+
path:
5+
description: 'Path to the php repository'
6+
required: true
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Setup PHP
11+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1
12+
with:
13+
php-version: 8.2
14+
tools: composer:v2
15+
16+
- name: Install dependencies
17+
run: composer install --prefer-dist --no-progress
18+
shell: bash
19+
working-directory: ${{ inputs.path }}
20+
21+
- name: Run PHP Code Sniffer
22+
run: composer run fmt
23+
shell: bash
24+
working-directory: ${{ inputs.path }}

.github/workflows/format.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
1-
name: PHP Format
1+
name: Format and Commit PHP Code
22

33
on:
4-
push:
5-
branches:
6-
- 'sdk-automation/**'
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
78

89
jobs:
910
format:
10-
if: ${{ github.event.commits != null && !startsWith(github.event.head_commit.message, 'style(fmt)') }}
11-
permissions:
12-
contents: write
1311
runs-on: ubuntu-latest
1412
steps:
15-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
13+
- name: Checkout
14+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
1615
with:
1716
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
1817

19-
- name: Setup PHP
20-
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1
18+
- name: Format PHP Code
19+
uses: ./.github/actions/format
2120
with:
22-
php-version: 8.2
23-
tools: composer:v2
24-
25-
- name: Install dependencies
26-
run: composer install --prefer-dist --no-progress
27-
28-
- name: Run PHP Code Sniffer
29-
run: composer run fmt || true
21+
path: .
3022

31-
- run: |
23+
- name: Commit and Push Changes
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
26+
run: |
3227
git config user.name AdyenAutomationBot
3328
git config user.email "${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}"
3429
git add .
3530
git commit -m "style(fmt): code formatted" || echo "No changes to commit"
36-
git push
31+
git push

0 commit comments

Comments
 (0)