From 543e8f5b78035b8457445845dd5fcfe323f107db Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 27 Aug 2024 14:59:07 +0100 Subject: [PATCH] ci: trigger CI via comment and label (#11849) * ci: trigger CI via comment and label * fix: reduce parenthesis --- .github/workflows/preview-comment.yml | 19 +++++++++++++++++++ .github/workflows/preview-release.yml | 17 +++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/preview-comment.yml diff --git a/.github/workflows/preview-comment.yml b/.github/workflows/preview-comment.yml new file mode 100644 index 000000000000..7ed6bdf6f680 --- /dev/null +++ b/.github/workflows/preview-comment.yml @@ -0,0 +1,19 @@ +name: Add continuous release label + +on: + issue_comment: + types: [created] + +permissions: + pull-requests: write + +jobs: + label: + if: ${{ github.repository_owner == 'withastro' && startsWith(github.event.comment.body, '!preview') }} + runs-on: ubuntu-latest + + steps: + - run: | + gh issue edit ${{ github.event.issue.number }} --add-label "pr: preview" --repo ${{ github.repository }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index 225efe402a77..df6a44f4848c 100644 --- a/.github/workflows/preview-release.yml +++ b/.github/workflows/preview-release.yml @@ -1,18 +1,18 @@ name: Preview release on: - workflow_dispatch: - issue_comment: - types: [created] + pull_request: + branches: [main] + types: [opened, synchronize, labeled, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number }} + cancel-in-progress: true permissions: contents: read actions: write -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }} @@ -24,7 +24,8 @@ env: jobs: preview: - if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && (startsWith(github.event.comment.body, '!preview')) }} + if: | + ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && contains(github.event.pull_request.labels.*.name, 'pr: preview') }} runs-on: ubuntu-latest permissions: contents: read