Skip to content

Commit 0e8eedc

Browse files
committed
feat: try auto-release of symfony bundle
1 parent 073c4d5 commit 0e8eedc

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Sync Symfony Twig Component Bundle upon Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
sync:
9+
runs-on: ubuntu-latest
10+
env:
11+
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Get previous tag
19+
id: previoustag
20+
run: |
21+
echo "tag=$(git describe --tags --abbrev=0 HEAD^)" >> $GITHUB_OUTPUT
22+
23+
- name: Check if subfolder changed
24+
id: diff
25+
run: |
26+
if git diff --quiet ${{ steps.previoustag.outputs.tag }} HEAD -- templates/twig-component; then
27+
echo "changed=false" >> $GITHUB_OUTPUT
28+
else
29+
echo "changed=true" >> $GITHUB_OUTPUT
30+
fi
31+
32+
- name: Sync folder to secondary repo
33+
if: steps.diff.outputs.changed == 'true'
34+
run: |
35+
git clone https://github.com/vardumper/html5-twig-component-bundle.git target
36+
rm -rf target/*
37+
cp -R templates/twig-component/* target/
38+
cd target
39+
40+
# Update version in composer.json
41+
release_version="${GITHUB_REF_NAME#v}" # Strip leading "v" if present
42+
43+
# Update "version" key in composer.json
44+
jq --arg v "$release_version" '.version = $v' composer.json > composer.json.tmp
45+
mv composer.json.tmp composer.json
46+
47+
git config user.name "GitHub Actions"
48+
git config user.email "actions@github.com"
49+
git add .
50+
git commit -m "Sync from ${GITHUB_REPOSITORY} release ${GITHUB_REF_NAME}" || echo "No changes"
51+
git push
52+
53+
- name: Create release in target repo
54+
if: steps.diff.outputs.changed == 'true'
55+
run: |
56+
gh release create ${{ github.ref_name }} \
57+
--repo vardumper/html5-twig-component-bundle \
58+
--notes "Auto-synced from ${GITHUB_REPOSITORY} release ${GITHUB_REF_NAME}"

0 commit comments

Comments
 (0)