Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
ci: fix deploy 2
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 committed Jun 17, 2023
1 parent dd61a69 commit cf8f27f
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions .github/workflows/maven-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,57 +57,53 @@ jobs:

- name: Deploy
id: deployRequest
uses: fjogeleit/http-request-action@master
with:
url: ${{ secrets.DEPLOY_URL }}
method: 'POST'
bearerToken: ${{ secrets.DEPLOY_KEY }}
ignoreStatusCodes: '500'
timeout: 600000

- name: Show Response
run: echo ${{ steps.deployRequest.outputs.response }}
run: |
curl -i -X POST -H 'Authorization: Bearer ${{ secrets.DEPLOY_KEY }}' "${{ secrets.DEPLOY_URL }}" > response.txt
cat response.txt
- name: Is Successful Deploy
if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'SUCCESSFUL' }}
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
# :white_check_mark: デプロイが完了しました
if: ${{ success() }}
run: |
cat <<EOF > comment.txt
# :white_check_mark: デプロイが完了しました
プルリクエストがマージされたため、本番環境へのデプロイを行いました。
バージョンは \`${{ needs.maven-ci.outputs.version }}\` です。
反映は本番環境の再起動後ですので、アクティブログインユーザーの同意を得て再起動するか、3時の自動再起動を待ってください。
プルリクエストがマージされたため、本番環境へのデプロイを行いました。
バージョンは `${{ needs.maven-ci.outputs.version }}` です。稼働中バージョンの確認は Minecraft サーバ内で `/ver AntiAlts3` を実行することで確認できます。
反映は本番環境の再起動後ですので、アクティブログインユーザーの同意を得て再起動するか、3時の自動再起動を待ってください。
https://github.com/${{ github.repository }}/releases/tag/${{ needs.maven-ci.outputs.tag }}
EOF
https://github.com/${{ github.repository }}/releases/tag/${{ needs.maven-ci.outputs.tag }}
gh pr comment ${{ github.event.pull_request.number }} -R ${{ github.repository }} -F comment.txt
- name: Is Failed Deploy
if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'ERROR' }}
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
# :x: デプロイに失敗しました
if: ${{ failure() }}
run: |
cat <<EOF > comment.txt
# :x: デプロイに失敗しました
プルリクエストがマージされたため、本番環境へのデプロイを行おうとしましたが失敗しました。
エラー内容は以下の通りです。
\`\`\`
$(cat response.txt)
\`\`\`
プルリクエストがマージされたため、本番環境へのデプロイを行おうとしましたが失敗しました。
エラー内容は以下の通りです。
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
EOF
```
${{ fromJson(steps.deployRequest.outputs.response).type }} (${{ fromJson(steps.deployRequest.outputs.response).type_ja }}) - ${{ fromJson(steps.deployRequest.outputs.response).status }} (${{ fromJson(steps.deployRequest.outputs.response).status_ja }})
${{ fromJson(steps.deployRequest.outputs.response).message }}
```
gh pr comment ${{ github.event.pull_request.number }} -R ${{ github.repository }} -F comment.txt
- name: Is Successful Deploy
if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'SUCCESSFUL' }}
if: ${{ success() }}
uses: chrnorm/deployment-status@v2.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
state: success
deployment-id: ${{ steps.deployment.outputs.deployment_id }}

- name: Update deployment status (failure)
if: ${{ failure() || fromJson(steps.deployRequest.outputs.response).status == 'ERROR' }}
if: ${{ failure() }}
uses: chrnorm/deployment-status@v2.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit cf8f27f

Please sign in to comment.