From bdadc8de2ce903513aca2dfb333b9c23320fe648 Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Mon, 22 Jul 2024 23:30:49 +0100 Subject: [PATCH 1/2] chore: add possibility to call deploy workflow from Contentful --- .github/workflows/cd.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9d3a8b5..dfaea52 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,14 +1,16 @@ on: workflow_call: + repository_dispatch: + types: [publish-event] jobs: build: runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} + environment: ${{ (github.event.client_payload.env && github.event_name == 'repository_dispatch') && github.event.client_payload.env || (github.ref == 'refs/heads/master' && 'production' || 'staging') }} env: VM_CONTENTFUL_SPACE: ${{ secrets.VM_CONTENTFUL_SPACE }} VM_CONTENTFUL_ACCESS_TOKEN: ${{ secrets.VM_CONTENTFUL_ACCESS_TOKEN }} - VM_CONTENTFUL_ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} + VM_CONTENTFUL_ENVIRONMENT: ${{ (github.event.client_payload.env && github.event_name == 'repository_dispatch') && github.event.client_payload.env || (github.ref == 'refs/heads/master' && 'production' || 'staging') }} outputs: ENVIRONMENT: ${{ env.VM_CONTENTFUL_ENVIRONMENT }} steps: From bfebe0676db2d6197aa578347ea3a3d80e862d38 Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Mon, 22 Jul 2024 23:38:42 +0100 Subject: [PATCH 2/2] chore: update ci workflow to also check pr username before triggering deploy --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 060e325..c621446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: deploy: if: > - (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || (github.event.pull_request.base.ref == 'develop' && github.event.pull_request.head.repo.full_name == github.repository)) + (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || (github.event.pull_request.base.ref == 'develop' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login == 'valerymelou')) needs: test uses: ./.github/workflows/cd.yml secrets: inherit