diff --git a/.github/workflows/pull-request-preview-cleanup.yml b/.github/workflows/pull-request-preview-cleanup.yml index f8fea1f..22a7b95 100644 --- a/.github/workflows/pull-request-preview-cleanup.yml +++ b/.github/workflows/pull-request-preview-cleanup.yml @@ -6,12 +6,12 @@ on: pull_request_target: types: [closed] -permissions: - contents: read - # deployments: write - pull-requests: write - statuses: write - issues: write +# permissions: +# contents: read +# deployments: write +# pull-requests: write +# statuses: write +# issues: write jobs: cleanup: @@ -71,13 +71,13 @@ jobs: # env: # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Send confirmation - id: send_confirmation - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/issues/:issue_id/comments - repository: ${{ github.repository }} - issue_id: ${{ github.event.number }} - body: "removed the deployment on " - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + # - name: Send confirmation + # id: send_confirmation + # uses: octokit/request-action@v2.x + # with: + # route: POST /repos/:repository/issues/:issue_id/comments + # repository: ${{ github.repository }} + # issue_id: ${{ github.event.number }} + # body: "removed the deployment on " + # env: + # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/pull-request-preview.yml b/.github/workflows/pull-request-preview.yml index b961319..ebe6cf5 100644 --- a/.github/workflows/pull-request-preview.yml +++ b/.github/workflows/pull-request-preview.yml @@ -26,7 +26,7 @@ on: permissions: contents: read - # deployments: write + deployments: write pull-requests: write statuses: write issues: write @@ -45,31 +45,31 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - # - name: create deployment - # id: create_deployment - # uses: octokit/request-action@v2.x - # with: - # route: POST /repos/:repository/deployments - # repository: ${{ github.repository }} - # ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }} - # environment: dev - # auto_merge: false - # required_contexts: "[]" - # env: - # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: create deployment + id: create_deployment + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments + repository: ${{ github.repository }} + ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }} + environment: dev + auto_merge: false + required_contexts: "[]" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - # - name: set deployment status to in progress - # id: start_deployment - # uses: octokit/request-action@v2.x - # with: - # route: POST /repos/:repository/deployments/:deployment/statuses - # repository: ${{ github.repository }} - # deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} - # environment: dev - # log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - # state: in_progress - # env: - # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: set deployment status to in progress + id: start_deployment + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} + environment: dev + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + state: in_progress + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # deployment goes here - name: Checkout @@ -89,41 +89,41 @@ jobs: - name: deploy to surge run: npm run surge -- --token "${{ secrets.SURGE_TOKEN }}" --domain liputenpotest-${{ github.event.number }}.surge.sh - # - name: set deployment status to success - # id: successful_deployment - # uses: octokit/request-action@v2.x - # with: - # route: POST /repos/:repository/deployments/:deployment/statuses - # repository: ${{ github.repository }} - # deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} - # environment: dev - # environment_url: https://liputenpotest-${{ github.event.number }}.surge.sh - # log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - # state: success - # env: - # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - # - name: set deployment status to failure - # id: failed_deployment - # uses: octokit/request-action@v2.x - # if: failure() - # with: - # route: POST /repos/:repository/deployments/:deployment/statuses - # repository: ${{ github.repository }} - # deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} - # environment: dev - # log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - # state: failure - # env: - # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: set deployment status to success + id: successful_deployment + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} + environment: dev + environment_url: https://liputenpotest-${{ github.event.number }}.surge.sh + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + state: success + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Send confirmation - id: send_confirmation + - name: set deployment status to failure + id: failed_deployment uses: octokit/request-action@v2.x + if: failure() with: - route: POST /repos/:repository/issues/:issue_id/comments + route: POST /repos/:repository/deployments/:deployment/statuses repository: ${{ github.repository }} - issue_id: ${{ github.event.number }} - body: "deployed to " + deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} + environment: dev + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + state: failure env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + # - name: Send confirmation + # id: send_confirmation + # uses: octokit/request-action@v2.x + # with: + # route: POST /repos/:repository/issues/:issue_id/comments + # repository: ${{ github.repository }} + # issue_id: ${{ github.event.number }} + # body: "deployed to " + # env: + # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"