-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (72 loc) · 2.55 KB
/
migration-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Check for missing migrations
on:
pull_request:
branches: [ main ]
jobs:
sync:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Checkout db
uses: actions/checkout@v4
with:
repository: minvws/nl-rdo-databases
ref: 'main'
token: ${{ secrets.repo_read_only_token }}
path: './database'
- name: check for missing migrations
id: migration_check
run: |
# Run the script and store the output
set +e
OUT="$(sh .github/scripts/check-missing-migrations.sh)"
RETVAL=$?
set -e
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64 | tr -dc 'a-zA-Z0-9')
{
echo "output<<$EOF"
echo "$OUT"
echo "$EOF"
if [[ $RETVAL -eq 1 ]] ; then
echo "missing_migrations=true"
else
echo "missing_migrations=false"
fi
} >> "$GITHUB_OUTPUT"
- name: debug it
run: |
echo ${{ steps }}
echo $GITHUB_OUTPUT
echo $GITHUB_STATE
# Find the comment
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Missing Database Migrations
# Create a comment when migrations are missing in the db repo
- name: Create comment
if: contains(steps.migration_check.outputs.missing_migrations, 'true')
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
## 🦙🦙 Missing Database Migrations detected
```
${{ steps.migration_check.outputs.output }}
```
👨💻 Please run `php bin/console woopie:sql:dump` to create the SQL migrations files, and add them to the database repository to get rid of this message.
# Remove comment if no missing migrations
- if: ${{ contains(steps.git.outputs.missing_migrations, 'false') && steps.fc.outputs.comment-id != '' }}
uses: actions/github-script@v7
with:
script: |
github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ steps.fc.outputs.comment-id }}
})