Skip to content

Commit af2cbe6

Browse files
authored
Merge pull request #129 from MekDrop/ci-fix-autobuild-5
CI: trying to autobuild work (I)
2 parents 30d1af2 + df7dab3 commit af2cbe6

File tree

1 file changed

+18
-70
lines changed

1 file changed

+18
-70
lines changed

.github/workflows/autobuild.yml

Lines changed: 18 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ concurrency:
99
group: 'autobuild'
1010
cancel-in-progress: true
1111

12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
1216
jobs:
1317
update-dist:
1418
runs-on: ubuntu-latest
@@ -25,102 +29,46 @@ jobs:
2529
- name: Install dependencies
2630
run: npm install
2731

32+
- name: Run format
33+
run: npm run format
34+
2835
- name: Run pack
2936
run: npm run pack
3037

31-
- name: Check changed files
32-
id: changed-files
33-
shell: bash
34-
run: |
35-
CHANGED_FILES=$(git diff --name-only)
36-
37-
if [ -z "$CHANGED_FILES" ]; then
38-
echo "No uncommitted changes detected."
39-
echo "any_changed=false" >> $GITHUB_OUTPUT
40-
echo "all_changed_files=''" >> $GITHUB_OUTPUT
41-
else
42-
echo "Uncommitted changes detected: $CHANGED_FILES"
43-
echo "any_changed=true" >> $GITHUB_OUTPUT
44-
# Format the changed files as a JSON array for proper parsing
45-
CHANGED_FILES_JSON=$(echo "$CHANGED_FILES" | jq -R -s -c 'split("\n") | map(select(length > 0))')
46-
echo "all_changed_files=$CHANGED_FILES_JSON" >> $GITHUB_OUTPUT
47-
fi
48-
4938
- name: Set current date as integer
50-
if: steps.changed-files.outputs.any_changed == 'true'
5139
id: date
5240
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
5341

5442
- name: Set Branch Name
55-
if: steps.changed-files.outputs.any_changed == 'true'
5643
id: set-branch
5744
run: echo "branch_name=autobuild-${{ steps.date.outputs.date }}" >> $GITHUB_OUTPUT
5845

59-
- name: Configure Git
60-
if: steps.changed-files.outputs.any_changed == 'true'
61-
run: |
62-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
63-
git config --local user.name "github-actions[bot]"
64-
65-
- name: Create and checkout branch
66-
if: steps.changed-files.outputs.any_changed == 'true'
67-
run: git checkout -b ${{ steps.set-branch.outputs.branch_name }}
68-
69-
- name: Add changed files
70-
if: steps.changed-files.outputs.any_changed == 'true'
71-
run: |
72-
# Add only the changed files from the previous step
73-
echo 'Changed files: ${{ steps.changed-files.outputs.all_changed_files }}'
74-
75-
# Parse the JSON array of changed files
76-
echo '${{ steps.changed-files.outputs.all_changed_files }}' | jq -c '.[]' | while read -r file; do
77-
# Remove quotes from the file path
78-
file=$(echo $file | tr -d '"')
79-
80-
if [[ $file == dist/* ]]; then
81-
git add "$file"
82-
echo "Adding $file to commit"
83-
fi
84-
done
85-
86-
- name: Commit changes
87-
if: steps.changed-files.outputs.any_changed == 'true'
88-
id: commit
89-
continue-on-error: true
90-
run: |
91-
# Check if there are any staged changes to commit
92-
if git diff --staged --quiet; then
93-
echo "No changes to commit in dist/ directory"
94-
echo "has_changes=false" >> $GITHUB_OUTPUT
95-
else
96-
git commit -m "[autobuild] dist update"
97-
echo "has_changes=true" >> $GITHUB_OUTPUT
98-
fi
99-
100-
- name: Push branch
101-
if: steps.changed-files.outputs.any_changed == 'true' && steps.commit.outputs.has_changes == 'true'
102-
run: git push -u origin ${{ steps.set-branch.outputs.branch_name }}
103-
10446
- name: Create Pull Request
10547
if: steps.changed-files.outputs.any_changed == 'true' && steps.commit.outputs.has_changes == 'true'
106-
id: create-pr
107-
uses: peter-evans/create-pull-request@v6
48+
id: create_pr
49+
uses: peter-evans/create-pull-request@v7
10850
with:
10951
token: ${{ secrets.GITHUB_TOKEN }}
11052
branch: ${{ steps.set-branch.outputs.branch_name }}
11153
title: "[AUTOBUILD] ${{ steps.date.outputs.date }}"
11254
body: "Auto-generated update to dist/ from latest main push"
11355
base: main
114-
labels: autobuild
56+
labels: |
57+
autobuild
58+
commit-message: "autobuild"
59+
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
60+
delete-branch: true
61+
signoff: false
62+
maintainer-can-modify: false
11563

11664
- name: Sleep for 30 seconds
117-
if: steps.changed-files.outputs.any_changed == 'true' && steps.commit.outputs.has_changes == 'true'
65+
if: ${{ steps.create_pr.outputs.pull-request-number }}
11866
uses: juliangruber/sleep-action@v2.0.0
11967
with:
12068
time: 30s
12169

12270
- name: Auto-merge PR
123-
if: steps.changed-files.outputs.any_changed == 'true' && steps.commit.outputs.has_changes == 'true'
71+
if: ${{ steps.create_pr.outputs.pull-request-number }}
12472
uses: pascalgn/automerge-action@v0.15.0
12573
env:
12674
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)