Skip to content

Commit 31ee526

Browse files
authored
Refactor SQL bootstrap workflow for clarity and efficiency
1 parent a388cc3 commit 31ee526

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

.github/workflows/sql-bootstrap-expected.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ jobs:
1515
image: mysql:8
1616
env:
1717
MYSQL_ROOT_PASSWORD: rootpw
18-
ports:
19-
- 3306:3306
18+
ports: ["3306:3306"]
2019
options: >-
2120
--health-cmd="mysqladmin ping -h 127.0.0.1 -prootpw || exit 1"
22-
--health-interval=5s
23-
--health-timeout=3s
24-
--health-retries=60
21+
--health-interval=5s --health-timeout=3s --health-retries=60
2522
2623
steps:
24+
# 1) Immer den Default-Branch auschecken (nicht den Trigger-Branch)
2725
- uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.repository.default_branch }}
2828

29-
- name: Install MySQL client
29+
- name: Install MySQL client + make runner executable
3030
run: |
3131
sudo apt-get update
3232
sudo apt-get install -y mysql-client
@@ -42,24 +42,31 @@ jobs:
4242
RECORD: "1"
4343
run: ./tests/run_tests.sh
4444

45-
- name: Commit changes
45+
- name: Commit changes on new branch
46+
id: commit
4647
run: |
48+
set -e
49+
BR="bootstrap-expected-${GITHUB_RUN_ID}"
4750
git config user.name "github-actions[bot]"
4851
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
49-
git checkout -b bootstrap-expected
52+
git checkout -b "$BR"
5053
git add tests/expected/*.csv || true
5154
if git diff --cached --quiet; then
52-
echo "No expected files to commit."
55+
echo "changed=false" >> $GITHUB_OUTPUT
5356
else
5457
git commit -m "Bootstrap expected CSVs"
55-
git push -u origin bootstrap-expected
58+
git push -u origin "$BR"
59+
echo "changed=true" >> $GITHUB_OUTPUT
60+
echo "branch=$BR" >> $GITHUB_OUTPUT
5661
fi
5762
5863
- name: Create pull request
64+
if: steps.commit.outputs.changed == 'true'
5965
uses: peter-evans/create-pull-request@v6
6066
with:
6167
token: ${{ secrets.GITHUB_TOKEN }}
62-
branch: bootstrap-expected
68+
base: ${{ github.event.repository.default_branch }} # z. B. main
69+
branch: ${{ steps.commit.outputs.branch }} # neuer Branch
6370
title: "Bootstrap expected CSVs"
6471
body: "Erzeugt Expected-Dateien aus aktuellen SQL-Ausgaben."
6572
delete-branch: true

0 commit comments

Comments
 (0)