diff --git a/.github/workflows/00-init.yml b/.github/workflows/00-init.yml index d6989cc38239..613b79e12c20 100644 --- a/.github/workflows/00-init.yml +++ b/.github/workflows/00-init.yml @@ -17,6 +17,11 @@ jobs: ASSET_INIT_VECTOR: ${{ secrets.ASSET_INIT_VECTOR }} ASSET_PASSWORD: ${{ secrets.ASSET_PASSWORD }} +# - name: 🚮 Dump GitHub context for debugging +# env: +# GITHUB_CONTEXT: ${{ toJson(github) }} +# run: echo "$GITHUB_CONTEXT" + - name: 💀 Killing me softly uses: ./.github/actions/cancel-workflow if: failure() diff --git a/.github/workflows/02-e2e-regenerate.yml b/.github/workflows/02-e2e-regenerate.yml index ab388950cdae..cfd42a115c43 100644 --- a/.github/workflows/02-e2e-regenerate.yml +++ b/.github/workflows/02-e2e-regenerate.yml @@ -90,7 +90,7 @@ jobs: with: name: snapshots-${{ inputs.type }} path: ./__snapshots__/*/component - retention-days: 30 + retention-days: 7 - name: 🆙 Upload foundations if: always() && inputs.type == 'foundations' @@ -98,7 +98,7 @@ jobs: with: name: snapshots-${{ inputs.type }} path: ./__snapshots__/foundations - retention-days: 30 + retention-days: 7 - name: 🆙 Upload patternhub if: always() && inputs.type == 'patternhub' @@ -106,7 +106,7 @@ jobs: with: name: snapshots-${{ inputs.type }} path: ./__snapshots__/*/patternhub - retention-days: 30 + retention-days: 7 - name: 🆙 Upload showcase if: always() && inputs.type == 'showcases' @@ -114,4 +114,4 @@ jobs: with: name: snapshots-${{ inputs.type }} path: ./__snapshots__/*/showcase - retention-days: 30 + retention-days: 7 diff --git a/.github/workflows/02-e2e-regenerated-snapshots-commit.yml b/.github/workflows/02-e2e-regenerated-snapshots-commit.yml new file mode 100644 index 000000000000..10f633bbba06 --- /dev/null +++ b/.github/workflows/02-e2e-regenerated-snapshots-commit.yml @@ -0,0 +1,100 @@ +name: Commit Regenerated Snapshots + +on: + workflow_call: + inputs: + components: + description: "Regenerate snapshots for components" + required: true + type: boolean + foundations: + description: "Regenerate snapshots for foundations" + required: true + type: boolean + patternhub: + description: "Regenerate snapshots for patternhub" + required: true + type: boolean + showcases: + description: "Regenerate snapshots for showcases" + required: true + type: boolean + +jobs: + commit-showcases: + name: 🆙 Commit regenerated snapshots + if: (inputs.showcases || inputs.components || inputs.foundations || inputs.patternhub) && !contains(github.actor,'[bot]') + runs-on: ubuntu-24.04 # Use Ubuntu 24.04 explicitly + permissions: + contents: write + pull-requests: write + env: + NEW_PR_BRANCH: "${{ github.head_ref }}-auto" + steps: + - name: ⏬ Checkout repo + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: ⏬ Download components + uses: actions/download-artifact@v4 + # Only download artifact if the artifact exists + if: inputs.components + with: + name: snapshots-components + path: ./__snapshots__/ + + - name: ⏬ Download foundations + uses: actions/download-artifact@v4 + # Only download artifact if the artifact exists + if: inputs.foundations + with: + name: snapshots-foundations + path: ./__snapshots__/ + + - name: ⏬ Download patternhub + uses: actions/download-artifact@v4 + if: inputs.patternhub + with: + name: snapshots-patternhub + path: ./__snapshots__/ + + - name: ⏬ Download showcase + uses: actions/download-artifact@v4 + if: inputs.showcases + with: + name: snapshots-showcases + path: ./__snapshots__/ + + # https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow + - name: 🧬 Generate a token + id: generate-token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ vars.AUTO_MERGE_APP_ID }} + private-key: ${{ secrets.AUTO_MERGE_PRIVATE_KEY }} + + - name: 🏗️ Create new branch and commit changes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + + git checkout -b "$NEW_PR_BRANCH" + git add __snapshots__/* + + # We can't use semantic commits here because of the if statement in the workflow + git commit --no-verify -m "auto update snapshots" + git push -f origin "$NEW_PR_BRANCH" + + - name: 🪗 Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create --base ${{ github.head_ref }} --head "$NEW_PR_BRANCH" --title "Automated PR: Auto update snapshots" --body "This PR was created automatically by a GitHub Action." + + - name: 🤖 Squash the PR + run: gh pr merge --squash "$NEW_PR_BRANCH" + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index beaf49b5786d..3ba33923b60d 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -190,6 +190,23 @@ jobs: get-playwright-version ] + commit-regenerated-snapshots: + uses: ./.github/workflows/02-e2e-regenerated-snapshots-commit.yml + secrets: inherit + if: always() + needs: + [ + regenerate-snapshots-components, + regenerate-snapshots-foundations, + regenerate-snapshots-patternhub, + regenerate-snapshots + ] + with: + showcases: ${{ needs.regenerate-snapshots.result == 'success' }} + components: ${{ needs.regenerate-snapshots-components.result == 'success' }} + foundations: ${{ needs.regenerate-snapshots-foundations.result == 'success' }} + patternhub: ${{ needs.regenerate-snapshots-patternhub.result == 'success' }} + checks-done: if: ${{ always() }} runs-on: ubuntu-24.04 # Use Ubuntu 24.04 explicitly