Skip to content

Commit

Permalink
ci: fix deployment action
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogyuchi committed Aug 7, 2023
1 parent cfee035 commit 6c30c0a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ permissions: {}

jobs:
pre-deployment:
if: ${{ vars.CLOUDFLARE_PROJECT_NAME != '' }}
outputs:
branch: ${{ steps.get.outputs.branch }}
environment: ${{ steps.get.outputs.environment }}
Expand All @@ -40,7 +41,6 @@ jobs:
exit 1
fi
deployment:
if: ${{ vars.CLOUDFLARE_PROJECT_NAME != '' }}
needs: ["pre-deployment"]
env:
BRANCH: ${{ needs.pre-deployment.outputs.branch }}
Expand Down Expand Up @@ -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 "<a href='${{ github.event.repository.html_url }}/commit/$1'><code>$(echo "$1" | head -c 7)</code></a>"
}
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:
Expand All @@ -96,12 +105,15 @@ jobs:
body: |
<!-- DEPLOYMENT_COMMENT -->
<table><tr><td><strong>Latest commit:</strong> </td><td>
<code>${{ github.event.pull_request.head.sha }}</code>
${{ steps.comment-data.outputs.commit_text }}
</td></tr>
<tr><td><strong>Status:</strong></td><td>&nbsp;✅&nbsp; Deploy successful!</td></tr>
<tr><td><strong>Preview URL:</strong></td><td>
<a href='${{ steps.publish.outputs.url }}'>${{ steps.publish.outputs.url }}</a>
</td></tr>
<tr><td><strong>PR Preview URL:</strong></td><td>
<a href='${{ steps.comment-data.outputs.pr_preview_url }}'>${{ steps.comment-data.outputs.pr_preview_url }}</a>
</td></tr>
</table>
[View workflow logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }})
Expand All @@ -117,7 +129,7 @@ jobs:
body: |
<!-- DEPLOYMENT_COMMENT -->
<table><tr><td><strong>Latest commit:</strong> </td><td>
<code>${{ github.event.pull_request.head.sha }}</code>
${{ steps.comment-data.outputs.commit_text }}
</td></tr>
<tr><td><strong>Status:</strong></td><td>&nbsp;❌&nbsp; Deploy failed!</td></tr>
</table>
Expand Down

0 comments on commit 6c30c0a

Please sign in to comment.