Skip to content

Commit 16ad003

Browse files
Merge pull request #28 from Laravel-Lang/andrey-helldar-patch-1
Refactor GitHub Actions workflow for updates
2 parents 7a556f9 + 22d8cca commit 16ad003

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

.github/workflows/update.yml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
workflow_dispatch:
78

89
permissions: write-all
910

@@ -12,45 +13,37 @@ jobs:
1213
runs-on: ubuntu-latest
1314

1415
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v6
16+
- uses: actions/checkout@v6
1717

18-
- name: Setup PHP
19-
uses: shivammathur/setup-php@v2
18+
- uses: shivammathur/setup-php@v2
2019
with:
2120
php-version: '8.4'
2221
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv, json
2322
coverage: none
2423

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

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

52-
- name: Push changes
53-
uses: ad-m/github-push-action@master
54-
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
5534
with:
56-
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)