From cfee035d46e795dd00d4ab6bc93ed89d9a17f69f Mon Sep 17 00:00:00 2001 From: Mogyuchi Date: Mon, 7 Aug 2023 02:02:05 +0900 Subject: [PATCH 1/2] ci: Update deploy.yml (#355) --- .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 15c85a47..32752f17 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -66,7 +66,7 @@ jobs: with: ref: ${{ env.BRANCH }} - - run: mkdir _site && cp README.md _site/index.html + - run: mkdir _site && cp test _site/index.html - id: publish # This workflow does NOT work with v1.5.0 From 3601da75503ea82c01a830ba6405f7910ef8c4c3 Mon Sep 17 00:00:00 2001 From: Mogyuchi Date: Mon, 7 Aug 2023 19:20:24 +0900 Subject: [PATCH 2/2] ci: fix deployment action (#356) --- .github/workflows/deploy.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 32752f17..1ed4a390 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,6 +15,7 @@ permissions: {} jobs: pre-deployment: + if: ${{ vars.CLOUDFLARE_PROJECT_NAME != '' }} outputs: branch: ${{ steps.get.outputs.branch }} environment: ${{ steps.get.outputs.environment }} @@ -40,7 +41,6 @@ jobs: exit 1 fi deployment: - if: ${{ vars.CLOUDFLARE_PROJECT_NAME != '' }} needs: ["pre-deployment"] env: BRANCH: ${{ needs.pre-deployment.outputs.branch }} @@ -87,6 +87,15 @@ jobs: comment-author: "github-actions[bot]" body-includes: DEPLOYMENT_COMMENT + - id: comment-data + if: steps.fc.conclusion == 'success' + run: | + head_sha=$(git rev-parse HEAD) + get_short_sha_with_link() { + echo "$(echo "$1" | head -c 7)" + } + echo "commit_text=$(get_short_sha_with_link $(git rev-parse HEAD)) ( base: $(get_short_sha_with_link ${{ github.event.pull_request.base.sha }}) + head: $(get_short_sha_with_link ${{ github.event.pull_request.head.sha }}) )" >> "$GITHUB_OUTPUT" + echo "pr_preview_url=$(echo '${{ steps.publish.outputs.url }}' | perl -pe "s|(//).+?(\.)|\$1$(echo '${{ env.BRANCH }}' | perl -pe 's|/|-|g')\$2|")" >> "$GITHUB_OUTPUT" - if: steps.fc.conclusion == 'success' uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2 with: @@ -96,12 +105,15 @@ jobs: body: | +
Latest commit: - ${{ github.event.pull_request.head.sha }} + ${{ steps.comment-data.outputs.commit_text }}
Status: ✅  Deploy successful!
Preview URL: ${{ steps.publish.outputs.url }}
PR Preview URL: + ${{ steps.comment-data.outputs.pr_preview_url }} +
[View workflow logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}) @@ -117,7 +129,7 @@ jobs: body: |
Latest commit: - ${{ github.event.pull_request.head.sha }} + ${{ steps.comment-data.outputs.commit_text }}
Status: ❌  Deploy failed!