|
| 1 | +name: Weekly yarn.lock Refresh |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + target_branch: |
| 7 | + description: "Branch to refresh yarn.lock" |
| 8 | + required: true |
| 9 | + default: main |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - 0.79-stable |
| 13 | + - 0.78-stable |
| 14 | + |
| 15 | + schedule: |
| 16 | + - cron: '0 3 * * 1' # Every Monday at 3am UTC |
| 17 | + |
| 18 | +jobs: |
| 19 | + refresh-lockfile: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + branch: ${{ github.event_name == 'schedule' && fromJson('["main","0.80-stable","0.79-stable","0.78-stable"]') || fromJson(format('["{0}"]', github.event.inputs.target_branch)) }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Install GitHub CLI |
| 28 | + run: | |
| 29 | + sudo apt update |
| 30 | + sudo apt install -y gh |
| 31 | +
|
| 32 | + - name: Clone repo using gh CLI |
| 33 | + env: |
| 34 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + run: | |
| 36 | + gh auth setup-git |
| 37 | + gh repo clone "${{ github.repository }}" repo |
| 38 | + cd repo |
| 39 | + git checkout "${{ matrix.branch }}" |
| 40 | +
|
| 41 | + - name: Set up Node.js |
| 42 | + uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + node-version: '20' |
| 45 | + |
| 46 | + - name: Install Yarn |
| 47 | + run: npm install -g yarn |
| 48 | + |
| 49 | + - name: Delete yarn.lock and reinstall dependencies (skip scripts) |
| 50 | + working-directory: ./repo |
| 51 | + run: | |
| 52 | + echo "🧹 Removing yarn.lock..." |
| 53 | + rm -f yarn.lock |
| 54 | + echo "📦 Running yarn install without lifecycle scripts..." |
| 55 | + yarn install --ignore-scripts |
| 56 | +
|
| 57 | + - name: Commit and push changes via gh CLI |
| 58 | + working-directory: ./repo |
| 59 | + env: |
| 60 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + run: | |
| 62 | + git config user.name "github-actions[bot]" |
| 63 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 64 | +
|
| 65 | + BRANCH="chore/weekly-lock-refresh-${{ matrix.branch }}" |
| 66 | +
|
| 67 | + if git diff --quiet; then |
| 68 | + echo "🟢 No changes to commit." |
| 69 | + exit 0 |
| 70 | + fi |
| 71 | +
|
| 72 | + git checkout -B "$BRANCH" |
| 73 | + git add yarn.lock |
| 74 | + git commit -m "chore: weekly yarn.lock refresh for ${{ matrix.branch }}" |
| 75 | + git push --force --set-upstream "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git" "$BRANCH" |
| 76 | +
|
| 77 | + - name: Create Pull Request via GitHub CLI |
| 78 | + working-directory: ./repo |
| 79 | + env: |
| 80 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + run: | |
| 82 | + set -e |
| 83 | + PR_BODY=$(cat <<EOF |
| 84 | + ### Type of Change |
| 85 | + - Chore |
| 86 | + |
| 87 | + ### Why |
| 88 | + Updates Yarn.lock dependencies |
| 89 | + |
| 90 | + ### What |
| 91 | + Updated the yarn.lock to point to the new versions. |
| 92 | + Steps to upgrade: |
| 93 | + 1. Delete the older version from yarn.lock file |
| 94 | + 2. Execute yarn command so it can fetch the new versions. |
| 95 | + |
| 96 | + ## Screenshots |
| 97 | + |
| 98 | + |
| 99 | + ## Changelog |
| 100 | + Should this change be included in the release notes: no |
| 101 | + EOF |
| 102 | + ) |
| 103 | + |
| 104 | + if gh pr create \ |
| 105 | + --title "chore: Refresh yarn.lock for ${{ matrix.branch }} (weekly)" \ |
| 106 | + --body "$PR_BODY" \ |
| 107 | + --head "chore/weekly-lock-refresh-${{ matrix.branch }}" \ |
| 108 | + --base "${{ matrix.branch }}" \ |
| 109 | + --repo "${{ github.repository }}"; then |
| 110 | + echo "✅ PR created successfully for branch ${{ matrix.branch }}" |
| 111 | + else |
| 112 | + echo "ℹ️ PR may already exist or could not be created." |
| 113 | + fi |
0 commit comments