Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically update consumer sites on Scaffold release #1321

Open
AlexSkrypnyk opened this issue May 10, 2024 · 0 comments
Open

Automatically update consumer sites on Scaffold release #1321

AlexSkrypnyk opened this issue May 10, 2024 · 0 comments
Labels
State: Confirmed The issue was triaged and confirmed for development Type: Feature Issue is a new feature request
Milestone

Comments

@AlexSkrypnyk
Copy link
Member

We want the consumer sites to have PRs open with updates automatically when the Scaffold has a new version.

#1042 will allow to manually update Scaffold as a dependency on the consumer projects when there is a new Scaffold release via composer update drevops/scaffold.

Renovate config could pick up this update, but it will not run the plugins that would trigger the files updates. So Renovate cannot be used for this :(

The solution is to ship a custom GHA for a consumer site. The GHA would:

  1. Run on schedule daily to check for new versions of drevops/scaffold by running composer update drevops/scaffold.
  2. If there are changes found (the changes would be the updated files coming from Scaffol and auto-customised for the repo) - they will be committed to the repo in a new PR.
  3. Wrap this into action

Note that this is a monetisation feature of Scaffold. The first month or two will be for free. A token would need to be generated to use this.

Starting point

name: Synchronize Package Updates

on:
  schedule:
    # Runs every day at 05:00 UTC
    - cron:  '0 5 * * *'
  workflow_dispatch:

jobs:
  sync-updates:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout consumer repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up Git config
        run: |
          git config user.name "GitHub Actions"
          git config user.email "[email protected]"

      - name: Clone package repository
        run: |
          git clone https://github.com/yourusername/your-package-repo.git ./external-package

      - name: Copy updated files
        run: |
          cp -r ./external-package/path/to/files/* ./path/in/consumer/repo/

      - name: Check for changes
        id: file-check
        run: |
          if git diff --quiet; then
            echo "No changes detected."
            echo "has_changes=no" >> $GITHUB_ENV
          else
            echo "Changes detected."
            echo "has_changes=yes" >> $GITHUB_ENV

      - name: Commit and push if changes are detected
        if: env.has_changes == 'yes'
        run: |
          git checkout -b update-branch
          git add .
          git commit -m "Automatically update package files"
          git push origin update-branch

      - name: Create Pull Request
        if: env.has_changes == 'yes'
        uses: repo-sync/pull-request@v2
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          pr_title: "Automatically update package files"
          pr_body: "This is an auto-generated PR with updates from external package."
          pr_label: "auto-update"
          pr_branch: "update-branch"
          pr_reviewer: "username1,username2"  # Optional: Add reviewers if needed
          pr_assignee: "username"  # Optional: Assign to a user
@github-project-automation github-project-automation bot moved this to BACKLOG in Vortex May 10, 2024
@AlexSkrypnyk AlexSkrypnyk added this to the 2.1 milestone May 11, 2024
@AlexSkrypnyk AlexSkrypnyk added Type: Feature Issue is a new feature request State: Confirmed The issue was triaged and confirmed for development labels May 11, 2024
@AlexSkrypnyk AlexSkrypnyk modified the milestones: 24.12.0, 25.1.0 Sep 2, 2024
@AlexSkrypnyk AlexSkrypnyk modified the milestones: 25.1.0, 25.2.0 Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
State: Confirmed The issue was triaged and confirmed for development Type: Feature Issue is a new feature request
Projects
Status: BACKLOG
Development

No branches or pull requests

1 participant