diff --git a/.github/workflows/branch-deletion.yml b/.github/workflows/branch-deletion.yml new file mode 100644 index 00000000000..c851207e9ba --- /dev/null +++ b/.github/workflows/branch-deletion.yml @@ -0,0 +1,44 @@ +name: 🍃 Branch Deletion Workflow + +on: + delete: + branches: + - '*' +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_NAME: "" + BRANCH_NAME_FORMATTED_FOR_REPORTS: "" + +jobs: + delete-reports-folder: + name: Delete Reports Folder on GitHub Pages 🗑 + runs-on: ubuntu-latest + + steps: + - name: Checkout GitHub repository 📡 + uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Set up Git 🛠️ + run: | + git config user.email "actions@github.com" + git config user.name "GitHub Actions" + + - name: Extract branch name without prefix and format it 🌲 + run: | + BRANCH_NAME=$(echo "${{ github.event.ref }}" | sed 's/refs\/heads\///') + BRANCH_NAME_FORMATTED_FOR_REPORTS=$(echo "${BRANCH_NAME//\//_}") + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + echo "BRANCH_NAME_FORMATTED_FOR_REPORTS=$BRANCH_NAME_FORMATTED_FOR_REPORTS" >> $GITHUB_ENV + + - name: Delete Reports Folder 🗑 + run: | + git checkout github_pages + rm -rf "reports/vitest/$BRANCH_NAME_FORMATTED_FOR_REPORTS" + rm -rf "reports/stryker/$BRANCH_NAME_FORMATTED_FOR_REPORTS" + rm -rf "reports/cucumber/$BRANCH_NAME_FORMATTED_FOR_REPORTS" + git add . + git commit -m "chore(reports): delete reports folder for branch $BRANCH_NAME_FORMATTED_FOR_REPORTS" + git push origin github_pages \ No newline at end of file diff --git a/.github/workflows/upsert-pr-release.yml b/.github/workflows/upsert-pr-release.yml index e79e6e3e744..ff5855acfb5 100644 --- a/.github/workflows/upsert-pr-release.yml +++ b/.github/workflows/upsert-pr-release.yml @@ -53,6 +53,7 @@ jobs: - name: Merge main branch into develop branch 🤝 run: | + git config user.email "actions@github.com" git config user.name "GitHub Actions" git fetch --all git checkout main diff --git a/README.md b/README.md index d3828fef60e..825e11a78f6 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,7 @@ You can find all the workflows in the **[.github/workflows directory](https://gi | **[🔃️ Upsert PR Release Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/upsert-pr-release.yml)** | Creates or updates pull request to `main` depending on commits on `develop` since last release

[![🔃️ Upsert PR Release Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/upsert-pr-release.yml/badge.svg)](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/upsert-pr-release.yml) | `push` on `develop` | | **[🏷️ Release Creation Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/release-creation.yml)** | Creates a new release using `semantic-release` with tag and updated changelog

[![🏷️ Release Creation Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/release-creation.yml/badge.svg)](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/release-creation.yml) | `push` on `main` | | **[🚀 Deploy To Production Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/deploy-to-production.yml)** | Deploys app with last tag version to `Docker Hub` and `GCP`

[![🚀 Deploy To Production Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/deploy-to-production.yml/badge.svg)](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/deploy-to-production.yml) | `tag-creation` | +| **[🍃 Branch Deletion Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/branch-deletion.yml)** | Remove all reports for the deleted branch

[![🍃 Branch Deletion Workflow](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/branch-deletion.yml/badge.svg)](https://github.com/antoinezanardi/werewolves-assistant-web-next/actions/workflows/branch-deletion.yml) | `delete` on all branches | ## ✨ Misc commands