-
Notifications
You must be signed in to change notification settings - Fork 16
104 lines (96 loc) · 3.68 KB
/
generate_idehelper.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: generate idehelper
on:
push:
branches:
- dev
paths-ignore:
- 'README.md'
- 'renovate.json'
- '.github/workflows/update-dockerhub.yml'
- '.github/workflows/website_build.yml'
- 'docs'
workflow_dispatch: # Allows action to be run manually from the Actions tab
jobs:
regenerate-idehelper:
runs-on: 'ubuntu-latest'
permissions:
contents: write # Needed for pushing changes
pull-requests: write # Needed for creating pull requests
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.4.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: setup prereq
run: make env-file-dev; make docker-lan
- name: get dependencies
run: make composer-install-dev; make npm-install-gh
- name: make foldersctructure and layout images
run: make folder-structure-dev; make layout-images-dev
- name: spin up dev
run: make purge-cache; make generate-key-dev; make dev; make wait-mysql; sleep 10
- name: make regenerate-idehelper
run: make regenerate-idehelper
- name: Check for changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "Changes detected. Preparing to create a pull request."
echo "has_changes=true" >> $GITHUB_ENV
else
echo "No changes detected. Skipping pull request."
echo "has_changes=false" >> $GITHUB_ENV
fi
- name: Create new branch and push changes
if: env.has_changes == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
BRANCH_NAME="maint/update-ide-helper-$(date +%Y%m%d%H%M%S)"
echo "branch_name=${BRANCH_NAME}" >> $GITHUB_ENV
git checkout -b $BRANCH_NAME
git add .
git commit -m "Regenerate IDE helper files [ci]"
git push origin $BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for existing PR
if: env.has_changes == 'true'
id: check_pr
run: |
PR_NUMBER=$(gh pr list --base dev --state open --search "Auto-generated IDE helper update" --json number --jq '.[0].number' || echo "")
if [[ -n "$PR_NUMBER" ]]; then
echo "Existing PR found: #$PR_NUMBER"
echo "pr_number=$PR_NUMBER" >> $GITHUB_ENV
else
echo "No existing PR found."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Close existing PR (if found)
if: env.pr_number != ''
run: |
gh pr close ${{ env.pr_number }} --delete-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request (always create a new PR)
if: env.has_changes == 'true'
run: |
gh pr create \
--base dev \
--head ${{ env.branch_name }} \
--title "Auto-generated IDE helper update" \
--body "This PR updates the IDE helper files automatically."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up old branches
run: |
for branch in $(git branch -r | grep 'origin/maint/update-ide-helper-' | sed 's/origin\///'); do
if [[ "$branch" != "$branch_name" ]]; then
echo "Deleting old branch: $branch"
git push origin --delete "$branch"
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}