[スコア] @sor4chi #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Request | |
on: | |
issues: | |
types: | |
- opened | |
issue_comment: | |
types: | |
- created | |
env: | |
TZ: "Asia/Tokyo" | |
jobs: | |
request: | |
runs-on: ubuntu-20.04 | |
if: | | |
(contains(github.event.issue.labels.*.name, 'registration')) && ( | |
(github.event_name == 'issues') || ( | |
github.event_name == 'issue_comment' && | |
!github.event.issue.pull_request && | |
startsWith(github.event.comment.body, '/retry') && | |
(github.actor == github.event.issue.user.login) | |
) | |
) | |
steps: | |
- name: Initialize | |
uses: actions/[email protected] | |
if: github.event_name == 'issues' | |
with: | |
script: | | |
github.rest.issues.update({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: `[スコア] @${context.actor}`, | |
}); | |
- name: Comment | |
uses: peter-evans/[email protected] | |
if: github.event_name == 'issues' | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
**@${{ github.event.issue.user.login }} ようこそ Maximum WSH 2022 へ!** | |
- :racing_car: これから自動でスコアが計測されて、リーダーボードに反映されます | |
- :information_source: 計測中に、解決できない問題が発生した場合、 `@sor4chi` にご連絡ください | |
- :information_source: 計測先URLを変更するなど、登録内容を変更する場合は、issue を閉じて作り直してください | |
- name: Comment | |
uses: peter-evans/[email protected] | |
id: report-comment | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
:hourglass_flowing_sand: **計測する準備をしています** | |
- name: Parse issue's description | |
id: parse | |
uses: peter-murray/[email protected] | |
with: | |
issue_id: ${{ github.event.issue.number }} | |
label_marker_start: "{{" | |
label_marker_end: "}}" | |
- name: Create payload | |
uses: actions/[email protected] | |
with: | |
script: | | |
const fs = require('fs'); | |
const url = new URL(`${process.env.TARGET_URL}`); | |
const payload = { | |
id: process.env.USER_ID, | |
url: url.href, | |
issue_number: context.issue.number, | |
report_comment_id: process.env.REPORT_COMMENT_ID, | |
request_time: process.env.REQUEST_TIME, | |
}; | |
if (!['http:', 'https:'].includes(url.protocol)) { | |
console.error('Invalid url: %s', payload.url); | |
process.exit(1); | |
} | |
fs.writeFileSync('/tmp/payload.json', JSON.stringify(payload), 'utf-8'); | |
env: | |
USER_ID: ${{ github.event.issue.user.login }} | |
TARGET_URL: ${{ fromJSON(steps.parse.outputs.payload).url }} | |
REPORT_COMMENT_ID: ${{ steps.report-comment.outputs.comment-id }} | |
REQUEST_TIME: ${{ (github.event_name == 'issues' && github.event.issue.created_at) || github.event.comment.created_at }} | |
- name: Upload payload | |
uses: actions/[email protected] | |
with: | |
name: payload.json | |
path: /tmp/payload.json | |
retention-days: 1 | |
- name: Failure message | |
if: failure() | |
uses: peter-evans/[email protected] | |
with: | |
comment-id: ${{ steps.report-comment.outputs.comment-id }} | |
edit-mode: replace | |
body: | | |
:exclamation: **登録内容を読み込めませんでした** | |
次を確認して、もう一度 issue を作り直してください | |
- URL が間違っていませんか | |
- `http://` もしくは `https://` から始まる URL を入力してください | |
- issue の description を編集していませんか | |
- issue の description から登録情報を読み込むため、編集しないでください | |
--- | |
:information_source: 登録内容を変更する場合は、issue を閉じて作り直してください |