Skip to content

Commit 2c9de8e

Browse files
Merge pull request #54 from Laravel-Lang/andrey-helldar-patch-1
Refactor GitHub Actions workflow for updates
2 parents 9894742 + 24a79ac commit 2c9de8e

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

.github/workflows/update.yml

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,37 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v6
16+
- uses: actions/checkout@v6
1817

19-
- name: Setup PHP
20-
uses: shivammathur/setup-php@v2
18+
- uses: shivammathur/setup-php@v2
2119
with:
2220
php-version: '8.4'
2321
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv, json
2422
coverage: none
2523

26-
- name: Git setup
27-
if: success()
28-
run: |
29-
git config --local user.email "action@github.com"
30-
git config --local user.name "GitHub Action"
31-
32-
- name: Install dependencies
24+
- name: Install Composer dependencies
3325
run: composer update --prefer-stable --prefer-dist --no-progress --no-interaction
3426

3527
- name: Update data
3628
id: data
37-
if: success()
38-
run: |
39-
IS_DIRTY=1
40-
41-
composer collect
42-
43-
{ git add . && git commit -a -m "📦 Data updated"; } || IS_DIRTY=0
44-
45-
echo "is_dirty=${IS_DIRTY}" >> "$GITHUB_OUTPUT"
46-
47-
- name: Fix the code style
48-
uses: TheDragonCode/codestyler@v5
49-
with:
50-
github_token: ${{ secrets.COMPOSER_TOKEN }}
51-
fix: true
29+
run: composer collect
5230

53-
- name: Push changes
54-
uses: ad-m/github-push-action@master
55-
if: success() && steps.data.outputs.is_dirty == 1
31+
- name: Create a Pull Request
32+
uses: peter-evans/create-pull-request@v8
33+
id: pullRequest
5634
with:
57-
github_token: ${{ secrets.COMPOSER_TOKEN }}
35+
branch: projects/download
36+
branch-suffix: random
37+
delete-branch: true
38+
add-paths: ./data
39+
title: "[source]: Data updated"
40+
commit-message: 📦 Data updated
41+
body: 📦 Data updated
42+
labels: |
43+
source
44+
45+
- name: Merge PR
46+
if: ${{ steps.pullRequest.outputs.pull-request-number }}
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: gh pr merge --merge --auto ${{ steps.pullRequest.outputs.pull-request-number }}

0 commit comments

Comments
 (0)