From 01a8f82277a0210ecbb93f1f71cf2761659557e8 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 10:25:49 -0700 Subject: [PATCH 01/17] Add deploy action --- .github/workflows/deploy.yml | 21 +++++++++++++++++++++ now.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..15ee310a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,21 @@ +name: Deploy +on: push + +jobs: + deploy: + name: Preview + runs-on: + steps: + - uses: actions/checkout@master + - name: Vercel Action + uses: amondnet/vercel-action@v20.0.0 + id: vercel-action + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + github-comment: false + vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + - name: preview-url + run: | + echo ${{ steps.vercel-action.outputs.preview-url }} diff --git a/now.json b/now.json index fc489075..510c73a5 100644 --- a/now.json +++ b/now.json @@ -26,6 +26,6 @@ } ], "github": { - "silent": true + "enabled": false } } From 8b4ce08e954fcb4436237f8410d0e10f17818781 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 16:02:51 -0700 Subject: [PATCH 02/17] ubuntu --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 15ee310a..a3240a0f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,7 +4,7 @@ on: push jobs: deploy: name: Preview - runs-on: + runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: Vercel Action From 5a89ab6a1c0e4b6c15a9abe7c6ef402a0da53bba Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 16:15:59 -0700 Subject: [PATCH 03/17] Try creating a deployment status --- .github/workflows/deploy.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a3240a0f..fae201d7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,11 +2,18 @@ name: Deploy on: push jobs: - deploy: + deploy-preview: name: Preview runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: Preview + - name: Vercel Action uses: amondnet/vercel-action@v20.0.0 id: vercel-action @@ -19,3 +26,21 @@ jobs: - name: preview-url run: | echo ${{ steps.vercel-action.outputs.preview-url }} + + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + target_url: ${{ steps.vercel-action.outputs.preview-url }} + state: "success" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Update deployment status (failure) + if: failure() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + target_url: ${{ steps.vercel-action.outputs.preview-url }} + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} From bcfdf6404ab0162d0d6744e43cea0a5815e1962a Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 16:24:31 -0700 Subject: [PATCH 04/17] environment_url --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fae201d7..91f410ea 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,7 +32,7 @@ jobs: uses: chrnorm/deployment-status@releases/v1 with: token: ${{ secrets.GITHUB_TOKEN }} - target_url: ${{ steps.vercel-action.outputs.preview-url }} + environment_url: ${{ steps.vercel-action.outputs.preview-url }} state: "success" deployment_id: ${{ steps.deployment.outputs.deployment_id }} @@ -41,6 +41,5 @@ jobs: uses: chrnorm/deployment-status@releases/v1 with: token: ${{ secrets.GITHUB_TOKEN }} - target_url: ${{ steps.vercel-action.outputs.preview-url }} state: "failure" deployment_id: ${{ steps.deployment.outputs.deployment_id }} From d6f3282954a8d5dfece2043ad895be71faa611eb Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 18:25:02 -0700 Subject: [PATCH 05/17] test file count --- .github/workflows/deploy.yml | 104 ++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 91f410ea..87711899 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,45 +1,75 @@ name: Deploy -on: push - +on: + push: + paths: + - 'src/**' + - 'docs/**' + - '.github/workflows/deploy.yml' + - 'package.json' jobs: - deploy-preview: - name: Preview + test: + name: test runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - uses: chrnorm/deployment-action@releases/v1 - name: Create GitHub deployment - id: deployment - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment: Preview + - id: changeset-count + run: echo "::set-output name=CHANGE_COUNT::$(ls .changeset/*.md | grep -v README | wc -l | xargs)" + - run: echo "We have ${{ steps.changeset-count.outputs.CHANGE_COUNT}} files" + # deploy: + # # Run on main + # if: ${{ github.ref == 'refs/heads/main' }} + # name: Production + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@master + # - + # - name: Vercel Action + # uses: amondnet/vercel-action@v20.0.0 + # id: vercel-action + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + # github-comment: false + # vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - - name: Vercel Action - uses: amondnet/vercel-action@v20.0.0 - id: vercel-action - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} - github-comment: false - vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} - vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - - name: preview-url - run: | - echo ${{ steps.vercel-action.outputs.preview-url }} + # deploy-preview: + # # Don't run on main + # if: ${{ github.ref != 'refs/heads/main' }} + # name: Preview + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@master + # - uses: chrnorm/deployment-action@releases/v1 + # name: Create GitHub deployment + # id: deployment + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # environment: Preview - - name: Update deployment status (success) - if: success() - uses: chrnorm/deployment-status@releases/v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment_url: ${{ steps.vercel-action.outputs.preview-url }} - state: "success" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} + # - name: Vercel Action + # uses: amondnet/vercel-action@v20.0.0 + # id: vercel-action + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + # github-comment: false + # vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - - name: Update deployment status (failure) - if: failure() - uses: chrnorm/deployment-status@releases/v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - state: "failure" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} + # - name: Update deployment status (success) + # if: success() + # uses: chrnorm/deployment-status@releases/v1 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # environment_url: ${{ steps.vercel-action.outputs.preview-url }} + # state: "success" + # deployment_id: ${{ steps.deployment.outputs.deployment_id }} + + # - name: Update deployment status (failure) + # if: failure() + # uses: chrnorm/deployment-status@releases/v1 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # state: "failure" + # deployment_id: ${{ steps.deployment.outputs.deployment_id }} From cb14b94f515e11a92adc7d2b377951bc90eba2fb Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 18:27:23 -0700 Subject: [PATCH 06/17] check count --- .github/workflows/deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 87711899..02b66aaa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,7 +14,9 @@ jobs: - uses: actions/checkout@master - id: changeset-count run: echo "::set-output name=CHANGE_COUNT::$(ls .changeset/*.md | grep -v README | wc -l | xargs)" - - run: echo "We have ${{ steps.changeset-count.outputs.CHANGE_COUNT}} files" + - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 1 }} + name: Deploying to prod + run: echo "Deploying" # deploy: # # Run on main # if: ${{ github.ref == 'refs/heads/main' }} From b61b8b116937a45d52a811b94ea2055180c97135 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 18:28:27 -0700 Subject: [PATCH 07/17] check 0 --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 02b66aaa..6131710f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@master - id: changeset-count run: echo "::set-output name=CHANGE_COUNT::$(ls .changeset/*.md | grep -v README | wc -l | xargs)" - - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 1 }} + - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 0 }} name: Deploying to prod run: echo "Deploying" # deploy: From c79d892fffce2a9ebe4bacba098084ac74ff0e88 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 18:31:49 -0700 Subject: [PATCH 08/17] putting it together --- .github/workflows/deploy.yml | 112 +++++++++++++++++------------------ 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6131710f..c46a9951 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,71 +7,67 @@ on: - '.github/workflows/deploy.yml' - 'package.json' jobs: - test: - name: test + deploy: + # Run on main + if: ${{ github.ref == 'refs/heads/main' }} + name: Production runs-on: ubuntu-latest steps: - uses: actions/checkout@master + + # Check the number of changeset files, if it's 0 we deploy - id: changeset-count run: echo "::set-output name=CHANGE_COUNT::$(ls .changeset/*.md | grep -v README | wc -l | xargs)" + - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 0 }} - name: Deploying to prod - run: echo "Deploying" - # deploy: - # # Run on main - # if: ${{ github.ref == 'refs/heads/main' }} - # name: Production - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@master - # - - # - name: Vercel Action - # uses: amondnet/vercel-action@v20.0.0 - # id: vercel-action - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} - # github-comment: false - # vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} - # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + name: Vercel Action + uses: amondnet/vercel-action@v20.0.0 + id: vercel-action + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + vercel-args: '--prod' + github-comment: false + vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - # deploy-preview: - # # Don't run on main - # if: ${{ github.ref != 'refs/heads/main' }} - # name: Preview - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@master - # - uses: chrnorm/deployment-action@releases/v1 - # name: Create GitHub deployment - # id: deployment - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # environment: Preview + deploy-preview: + # Don't run on main + if: ${{ github.ref != 'refs/heads/main' }} + name: Preview + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: Preview - # - name: Vercel Action - # uses: amondnet/vercel-action@v20.0.0 - # id: vercel-action - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} - # github-comment: false - # vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} - # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + - name: Vercel Action + uses: amondnet/vercel-action@v20.0.0 + id: vercel-action + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + github-comment: false + vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - # - name: Update deployment status (success) - # if: success() - # uses: chrnorm/deployment-status@releases/v1 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # environment_url: ${{ steps.vercel-action.outputs.preview-url }} - # state: "success" - # deployment_id: ${{ steps.deployment.outputs.deployment_id }} + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment_url: ${{ steps.vercel-action.outputs.preview-url }} + state: "success" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} - # - name: Update deployment status (failure) - # if: failure() - # uses: chrnorm/deployment-status@releases/v1 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # state: "failure" - # deployment_id: ${{ steps.deployment.outputs.deployment_id }} + - name: Update deployment status (failure) + if: failure() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} From 120cdfe763d3de28b8b551e3e85321f0cc5de3e3 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Mon, 5 Apr 2021 18:40:16 -0700 Subject: [PATCH 09/17] Split into 2 deploy files --- .github/workflows/deploy_preview.yml | 50 +++++++++++++++++++ .../{deploy.yml => deploy_production.yml} | 39 +++++---------- 2 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/deploy_preview.yml rename .github/workflows/{deploy.yml => deploy_production.yml} (68%) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml new file mode 100644 index 00000000..a730ce5c --- /dev/null +++ b/.github/workflows/deploy_preview.yml @@ -0,0 +1,50 @@ +name: Deploy +on: + push: + branches-ignore: + - main + paths: + - 'src/**' + - 'docs/**' + - '.github/workflows/deploy*.yml' + - 'package.json' +jobs: + deploy-preview: + if: ${{ github.repository == 'primer/css' }} + name: Preview + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: Preview + + - name: Vercel Action + uses: amondnet/vercel-action@v20.0.0 + id: vercel-action + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + github-comment: false + vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment_url: ${{ steps.vercel-action.outputs.preview-url }} + state: "success" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Update deployment status (failure) + if: failure() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy_production.yml similarity index 68% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy_production.yml index c46a9951..ad953b26 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy_production.yml @@ -1,15 +1,16 @@ name: Deploy on: push: + branches: + - main paths: - 'src/**' - 'docs/**' - - '.github/workflows/deploy.yml' + - '.github/workflows/deploy*.yml' - 'package.json' jobs: deploy: - # Run on main - if: ${{ github.ref == 'refs/heads/main' }} + if: ${{ github.repository == 'primer/css' }} name: Production runs-on: ubuntu-latest steps: @@ -19,6 +20,14 @@ jobs: - id: changeset-count run: echo "::set-output name=CHANGE_COUNT::$(ls .changeset/*.md | grep -v README | wc -l | xargs)" + - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 0 }} + uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: Production + - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 0 }} name: Vercel Action uses: amondnet/vercel-action@v20.0.0 @@ -31,30 +40,6 @@ jobs: vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - deploy-preview: - # Don't run on main - if: ${{ github.ref != 'refs/heads/main' }} - name: Preview - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: chrnorm/deployment-action@releases/v1 - name: Create GitHub deployment - id: deployment - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment: Preview - - - name: Vercel Action - uses: amondnet/vercel-action@v20.0.0 - id: vercel-action - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} - github-comment: false - vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} - vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - - name: Update deployment status (success) if: success() uses: chrnorm/deployment-status@releases/v1 From 6fe622ddd09a226d7d6ad380db24946710511159 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 08:23:37 -0700 Subject: [PATCH 10/17] We don't need to update status because there's no pr and we don't use deployments tab --- .github/workflows/deploy_production.yml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/.github/workflows/deploy_production.yml b/.github/workflows/deploy_production.yml index ad953b26..49d6c6d5 100644 --- a/.github/workflows/deploy_production.yml +++ b/.github/workflows/deploy_production.yml @@ -20,14 +20,6 @@ jobs: - id: changeset-count run: echo "::set-output name=CHANGE_COUNT::$(ls .changeset/*.md | grep -v README | wc -l | xargs)" - - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 0 }} - uses: chrnorm/deployment-action@releases/v1 - name: Create GitHub deployment - id: deployment - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment: Production - - if: ${{ steps.changeset-count.outputs.CHANGE_COUNT == 0 }} name: Vercel Action uses: amondnet/vercel-action@v20.0.0 @@ -39,20 +31,3 @@ jobs: github-comment: false vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - - - name: Update deployment status (success) - if: success() - uses: chrnorm/deployment-status@releases/v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment_url: ${{ steps.vercel-action.outputs.preview-url }} - state: "success" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} - - - name: Update deployment status (failure) - if: failure() - uses: chrnorm/deployment-status@releases/v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - state: "failure" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} From bccf54f3a70c0111c114ddbac65fa364de9f1040 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 09:03:32 -0700 Subject: [PATCH 11/17] try getting existing deployments --- .github/workflows/deploy_preview.yml | 69 ++++++++++++++++------------ 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index a730ce5c..54d16d09 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -15,36 +15,47 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - uses: chrnorm/deployment-action@releases/v1 - name: Create GitHub deployment - id: deployment + - uses: actions/github-script@v3 + name: Cancel existing deployments with: - token: ${{ secrets.GITHUB_TOKEN }} - environment: Preview + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const deployments = await actions.getPendingDeploymentsForRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId, + }) + console.log(deployments) + # - uses: actions/github-script@v3 + # name: Create GitHub deployment + # id: deployment + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # environment: Preview - - name: Vercel Action - uses: amondnet/vercel-action@v20.0.0 - id: vercel-action - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} - github-comment: false - vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} - vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + # - name: Vercel Action + # uses: amondnet/vercel-action@v20.0.0 + # id: vercel-action + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + # vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + # github-comment: false + # vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - - name: Update deployment status (success) - if: success() - uses: chrnorm/deployment-status@releases/v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment_url: ${{ steps.vercel-action.outputs.preview-url }} - state: "success" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} + # - name: Update deployment status (success) + # if: success() + # uses: chrnorm/deployment-status@releases/v1 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # environment_url: ${{ steps.vercel-action.outputs.preview-url }} + # state: "success" + # deployment_id: ${{ steps.deployment.outputs.deployment_id }} - - name: Update deployment status (failure) - if: failure() - uses: chrnorm/deployment-status@releases/v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - state: "failure" - deployment_id: ${{ steps.deployment.outputs.deployment_id }} + # - name: Update deployment status (failure) + # if: failure() + # uses: chrnorm/deployment-status@releases/v1 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # state: "failure" + # deployment_id: ${{ steps.deployment.outputs.deployment_id }} From b61881061b83c4feabf52f5a0bfe85cfeb7d2184 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 09:04:29 -0700 Subject: [PATCH 12/17] github.actions --- .github/workflows/deploy_preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 54d16d09..ffdd4076 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -20,7 +20,7 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const deployments = await actions.getPendingDeploymentsForRun({ + const deployments = await github.actions.getPendingDeploymentsForRun({ owner: context.repo.owner, repo: context.repo.repo, run_id: context.runId, From 00d524f345c1ef27978570910eafc8247356f353 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 09:09:47 -0700 Subject: [PATCH 13/17] Create deployment --- .github/workflows/deploy_preview.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index ffdd4076..cfb71ead 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -20,10 +20,13 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const deployments = await github.actions.getPendingDeploymentsForRun({ + const deployments = await github.repos.createDeployment({ owner: context.repo.owner, repo: context.repo.repo, - run_id: context.runId, + ref: context.ref, + transient_environment: true, + environment: 'preview', + description: 'Deploying preview docs site.' }) console.log(deployments) # - uses: actions/github-script@v3 From f7a8b7d090089f9a6f3b9ccf2302917a68025f7f Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 09:17:31 -0700 Subject: [PATCH 14/17] preview-docs --- .github/workflows/deploy_preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index cfb71ead..8cd60dc8 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -25,7 +25,7 @@ jobs: repo: context.repo.repo, ref: context.ref, transient_environment: true, - environment: 'preview', + environment: 'preview-docs', description: 'Deploying preview docs site.' }) console.log(deployments) From f018ea50a4fd3149264a52cf22c96cda3bc78cc9 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 09:19:25 -0700 Subject: [PATCH 15/17] Use the sha --- .github/workflows/deploy_preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 8cd60dc8..7b420c59 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -23,7 +23,7 @@ jobs: const deployments = await github.repos.createDeployment({ owner: context.repo.owner, repo: context.repo.repo, - ref: context.ref, + ref: context.sha, transient_environment: true, environment: 'preview-docs', description: 'Deploying preview docs site.' From 46898c03e88f7aef082727a3e1d1a860e0026bcb Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 09:20:56 -0700 Subject: [PATCH 16/17] Remove transient info --- .github/workflows/deploy_preview.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 7b420c59..afb93fb3 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -24,7 +24,6 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, ref: context.sha, - transient_environment: true, environment: 'preview-docs', description: 'Deploying preview docs site.' }) From 22957e25df5431fc396c7f6ab24519999b899150 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 6 Apr 2021 09:22:59 -0700 Subject: [PATCH 17/17] revert back --- .github/workflows/deploy_preview.yml | 71 ++++++++++++---------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index afb93fb3..a730ce5c 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -15,49 +15,36 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - uses: actions/github-script@v3 - name: Cancel existing deployments + - uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - const deployments = await github.repos.createDeployment({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: context.sha, - environment: 'preview-docs', - description: 'Deploying preview docs site.' - }) - console.log(deployments) - # - uses: actions/github-script@v3 - # name: Create GitHub deployment - # id: deployment - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # environment: Preview + token: ${{ secrets.GITHUB_TOKEN }} + environment: Preview - # - name: Vercel Action - # uses: amondnet/vercel-action@v20.0.0 - # id: vercel-action - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} - # github-comment: false - # vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} - # vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + - name: Vercel Action + uses: amondnet/vercel-action@v20.0.0 + id: vercel-action + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + vercel-token: ${{ secrets.VERCEL_TOKEN_SHARED }} + github-comment: false + vercel-org-id: ${{ secrets.VERCEL_ORG_ID_SHARED }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - # - name: Update deployment status (success) - # if: success() - # uses: chrnorm/deployment-status@releases/v1 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # environment_url: ${{ steps.vercel-action.outputs.preview-url }} - # state: "success" - # deployment_id: ${{ steps.deployment.outputs.deployment_id }} + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment_url: ${{ steps.vercel-action.outputs.preview-url }} + state: "success" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} - # - name: Update deployment status (failure) - # if: failure() - # uses: chrnorm/deployment-status@releases/v1 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # state: "failure" - # deployment_id: ${{ steps.deployment.outputs.deployment_id }} + - name: Update deployment status (failure) + if: failure() + uses: chrnorm/deployment-status@releases/v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }}