|
9 | 9 | workflow_dispatch: |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - weekly-release: |
| 12 | + merge-weekly: |
13 | 13 | runs-on: ubuntu-latest |
14 | | - |
15 | | - env: |
16 | | - # Declare to satisfy linter, will be set dynamically during workflow execution |
17 | | - PR_NUMBER: "" |
18 | | - HAS_NEW_COMMITS: "" |
| 14 | + permissions: |
| 15 | + contents: write |
19 | 16 |
|
20 | 17 | steps: |
21 | 18 | - name: Checkout repository |
22 | 19 | uses: actions/checkout@v4 |
23 | 20 | with: |
24 | | - fetch-depth: 0 |
| 21 | + # Use a token with write permissions to push to the branch |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + fetch-depth: 0 # Fetch all history for merging |
25 | 24 |
|
26 | 25 | - name: Configure Git |
27 | 26 | run: | |
28 | 27 | git config user.name 'github-actions[bot]' |
29 | 28 | git config user.email 'github-actions[bot]@users.noreply.github.com' |
30 | 29 |
|
31 | | - - name: Check for new commits |
32 | | - shell: pwsh |
33 | | - run: | |
34 | | - # Check if there are commits between rel/weekly and main |
35 | | - $commitCount = git rev-list --count origin/rel/weekly..main |
36 | | - echo "HAS_NEW_COMMITS=$($commitCount -gt 0)" >> $env:GITHUB_ENV |
37 | | -
|
38 | | - - name: Create weekly release PR |
39 | | - if: ${{ env.HAS_NEW_COMMITS == 'true' }} |
40 | | - shell: pwsh |
41 | | - run: | |
42 | | - # Create PR from main to rel/weekly, capture created URL |
43 | | - $PR_URL = $(gh pr create ` |
44 | | - --base rel/weekly ` |
45 | | - --head main ` |
46 | | - --title "Scheduled weekly release $(Get-Date -Format 'yyyy-MM-dd')" ` |
47 | | - --fill-verbose ` |
48 | | - --reviewer michael-hawker) |
49 | | - |
50 | | - # Extract PR number from URL and set as environment variable |
51 | | - $PR_NUMBER = $($PR_URL | Select-String -Pattern '\d+$').Matches[0].Value |
52 | | - echo "PR_NUMBER=$PR_NUMBER" >> $env:GITHUB_ENV |
53 | | - env: |
54 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
55 | | - |
56 | | - - name: Enable auto-merge for the PR |
57 | | - if: ${{ env.HAS_NEW_COMMITS == 'true' }} |
58 | | - shell: pwsh |
| 30 | + - name: Merge main into rel/weekly |
59 | 31 | run: | |
60 | | - # Should result in fast-forward unless branch histories diverge |
61 | | - gh pr merge ${{ env.PR_NUMBER }} --auto --merge |
62 | | - env: |
63 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + git fetch origin |
| 33 | + git checkout rel/weekly |
| 34 | + git reset --hard origin/rel/weekly |
| 35 | + git merge --ff-only origin/main -m "Weekly merge of main into rel/weekly" |
| 36 | + git push origin rel/weekly |
| 37 | +
|
| 38 | + # Then trigger the build workflow on the updated rel/weekly branch |
| 39 | + trigger-build: |
| 40 | + needs: merge-weekly |
| 41 | + uses: CommunityToolkit/Labs-Windows/.github/workflows/build.yml@rel/weekly |
0 commit comments