From e81b983110b0052bf3ca379a70860696ec7dd49d Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:26:20 +0100 Subject: [PATCH] [TASK] Automatically update site package (#48) Releases: main --- .github/workflows/auto-pr-sitepackage.yml | 60 +++++++++++++++++++ Build/DownloadSitePackage/data.json | 13 ++++ .../generate_sitepackage.sh | 15 +++++ 3 files changed, 88 insertions(+) create mode 100644 .github/workflows/auto-pr-sitepackage.yml create mode 100644 Build/DownloadSitePackage/data.json create mode 100755 Build/DownloadSitePackage/generate_sitepackage.sh diff --git a/.github/workflows/auto-pr-sitepackage.yml b/.github/workflows/auto-pr-sitepackage.yml new file mode 100644 index 0000000..f2224c5 --- /dev/null +++ b/.github/workflows/auto-pr-sitepackage.yml @@ -0,0 +1,60 @@ +name: Auto PR for Site Package Changes + +on: + # Schedule to run daily at 2:00 AM UTC + schedule: + - cron: '0 2 * * *' + + # Manual trigger via "Run workflow" button in GitHub Actions UI + workflow_dispatch: + +jobs: + auto-pr: + name: Create PR for Site Package Changes + runs-on: ubuntu-latest + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_NAME: 'auto/sitepackage-update' + COMMIT_MESSAGE: 'Auto-update of site package files' + PR_TITLE: 'Automated Update of Site Package Files' + PR_BODY: 'This PR contains automatic updates to the site package files generated by the script.' + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set Up Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Run Generate Site Package Script + run: | + chmod +x Build/DownloadSitePackage/generate_sitepackage.sh + ./Build/DownloadSitePackage/generate_sitepackage.sh + + - name: Check for Changes + run: | + if git diff --quiet; then + echo "No changes detected, skipping PR creation." + exit 0 + fi + + - name: Create Branch + run: | + git checkout -b ${{ env.BRANCH_NAME }} + git add . + git commit -m "${{ env.COMMIT_MESSAGE }}" + + - name: Push Changes to New Branch + run: | + git push --force --set-upstream origin ${{ env.BRANCH_NAME }} + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ env.BRANCH_NAME }} + title: ${{ env.PR_TITLE }} + body: ${{ env.PR_BODY }} diff --git a/Build/DownloadSitePackage/data.json b/Build/DownloadSitePackage/data.json new file mode 100644 index 0000000..6b774ae --- /dev/null +++ b/Build/DownloadSitePackage/data.json @@ -0,0 +1,13 @@ +{ + "base_package": "site_package_tutorial", + "typo3_version": 13.4, + "title": "Site Package", + "description": "This site package is an example used to understand the TYPO3 Site Package Tutorial. ", + "repository_url": "https://github.com/TYPO3-Documentation/TYPO3CMS-Tutorial-SitePackage", + "author": { + "name": "TYPO3 Documentation Team", + "email": "j.doe@example.org", + "company": "T3docs", + "homepage": "https://docs.typo3.org/permalink/t3sitepackage:start" + } +} diff --git a/Build/DownloadSitePackage/generate_sitepackage.sh b/Build/DownloadSitePackage/generate_sitepackage.sh new file mode 100755 index 0000000..4a2b0d6 --- /dev/null +++ b/Build/DownloadSitePackage/generate_sitepackage.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +curl -X 'POST' \ + 'https://get.typo3.org/api/v1/sitepackage/' \ + -H 'accept: application/zip' \ + -H 'Content-Type: application/json' \ + -d @"$(dirname "$0")/data.json" --output my_site_package.zip + +rm -rf Classes +rm -rf Configuration +rm -rf ContentBlocks +rm -rf Initialisation +rm -rf Resources +unzip -o my_site_package.zip +rm my_site_package.zip