diff --git a/.github/workflows/e2e-delete-repo.yml b/.github/workflows/e2e-delete-repo.yml new file mode 100644 index 00000000..09493a6c --- /dev/null +++ b/.github/workflows/e2e-delete-repo.yml @@ -0,0 +1,20 @@ +name: Delete end-to-end test repos on PR close + +on: + pull_request_target: + types: + - closed + +jobs: + test: + name: Publish coverage comment + runs-on: ubuntu-latest + steps: + - run: | + gh repo delete --yes https://github.com/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-public || true + env: + GITHUB_TOKEN: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1 }} + - run: | + gh repo delete --yes https://github.com/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-private || true + env: + GITHUB_TOKEN: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2 }} diff --git a/.github/workflows/e2e-private-link-in-pr.yml b/.github/workflows/e2e-private-link-in-pr.yml new file mode 100644 index 00000000..e83bf51e --- /dev/null +++ b/.github/workflows/e2e-private-link-in-pr.yml @@ -0,0 +1,58 @@ +name: Post link to private end-to-end test repository + +on: + issue_comment: + types: [created] + +jobs: + invite: + name: Invite everyone to the e2e private repo + if: | + github.event.issue.pull_request + && contains(github.event.comment.body, '/invite') + runs-on: ubuntu-latest + strategy: + matrix: + collaborator: + - LOGIN: kieferro + PERMISSION: admin + ENABLED: "true" + + - LOGIN: ewjoachim + PERMISSION: admin + ENABLED: "true" + + - LOGIN: ${{ github.event.issue.user.login }} + PERMISSION: push + ENABLED: ${{ !contains(fromJson('["kieferro", "ewjoachim"]'), github.event.issue.user.login) }} + + steps: + + - name: Invite @${{ matrix.collaborator.LOGIN }} to the e2e private repo + run: gh api --method PUT /repos/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-private/collaborators/${LOGIN} -f permission=${PERMISSION} + if: ${{ matrix.collaborator.ENABLED == 'true' }} + env: + LOGIN: ${{ matrix.collaborator.LOGIN }} + NUMBER: ${{ github.event.issue.number }} + PERMISSION: ${{ matrix.collaborator.PERMISSION }} + GITHUB_TOKEN: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1 }} + + comment: + name: Add comment with link to e2e repos + if: | + github.event.issue.pull_request + && contains(github.event.comment.body, '/invite') + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - run: | + gh pr comment ${LINK} --body-file - <