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

Commit

Permalink
ci: actions/create-release to ncipollo/release-action (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 authored Jun 17, 2023
1 parent 3dae0e2 commit dd61a69
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 169 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/maven-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Maven でビルドを実行する。マージされたら、リリースを作成する。
# リリースが作成されたら、本番環境へデプロイする。

name: Maven

on:
pull_request:
branches:
- main
- master
types:
- opened
- synchronize
paths:
- .github/workflows/maven-ci.yml
pull_request_target:
branches:
- main
- master
types:
- opened
- synchronize
- reopened
- closed

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.merged == true && github.base_ref || github.event.pull_request.head.sha }}

jobs:
maven-ci:
name: Maven CI
uses: book000/templates/.github/workflows/reusable-maven.yml@master

deploy:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true

needs:
- maven-ci

steps:
- name: Create GitHub deployment
uses: chrnorm/[email protected]
id: deployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ needs.maven-ci.outputs.tag }}
environment: "production"
environment-url: https://github.com/${{ github.repository }}/releases/tag/${{ needs.maven-ci.outputs.tag }}

- name: Update deployment status (in_progress)
uses: chrnorm/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
state: in_progress
deployment-id: ${{ steps.deployment.outputs.deployment_id }}

- 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 }}

- 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: デプロイが完了しました
プルリクエストがマージされたため、本番環境へのデプロイを行いました。
バージョンは `${{ needs.maven-ci.outputs.version }}` です。稼働中バージョンの確認は Minecraft サーバ内で `/ver AntiAlts3` を実行することで確認できます。
反映は本番環境の再起動後ですので、アクティブログインユーザーの同意を得て再起動するか、3時の自動再起動を待ってください。
https://github.com/${{ github.repository }}/releases/tag/${{ needs.maven-ci.outputs.tag }}
- 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: デプロイに失敗しました
プルリクエストがマージされたため、本番環境へのデプロイを行おうとしましたが失敗しました。
エラー内容は以下の通りです。
```
${{ 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 }}
```
- name: Is Successful Deploy
if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'SUCCESSFUL' }}
uses: chrnorm/[email protected]
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' }}
uses: chrnorm/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
state: failure
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
24 changes: 0 additions & 24 deletions .github/workflows/maven.yml

This file was deleted.

145 changes: 0 additions & 145 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit dd61a69

Please sign in to comment.