Skip to content

Commit 18ac6cc

Browse files
authored
Merge branch 'develop' into add_mock_header
2 parents 5b8fd77 + c887b57 commit 18ac6cc

68 files changed

Lines changed: 3720 additions & 1906 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockle-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.7
1+
0.4.9

.github/workflows/add-to-task-list.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
add-to-task-list:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: dev-hato/actions-add-to-projects@v0.0.10
14+
- uses: dev-hato/actions-add-to-projects@v0.0.16
1515
with:
1616
github_app_id: ${{ secrets.PROJECT_AUTOMATION_APP_ID }}
1717
github_app_private_key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ jobs:
5454
# make release
5555
- name: Perform CodeQL Analysis
5656
uses: github/codeql-action/analyze@v2
57+
58+
concurrency:
59+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
60+
cancel-in-progress: true

.github/workflows/deploy-hato-bot.yml

Lines changed: 22 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
env:
2323
DOCKER_BUILDKIT: 1
2424
COMPOSE_DOCKER_CLI_BUILD: 1
25+
REPOSITORY: ${{github.repository}}
2526
permissions:
2627
contents: read
2728
packages: write
@@ -33,23 +34,22 @@ jobs:
3334
- name: Set .env
3435
run: cp .env.example .env
3536
- name: Login to GitHub Container Registry
36-
uses: docker/login-action@v2
37+
uses: docker/login-action@v2.1.0
3738
with:
3839
registry: ghcr.io
3940
username: ${{ github.actor }}
4041
password: ${{ secrets.GITHUB_TOKEN }}
4142
- name: Set up QEMU
42-
uses: docker/setup-qemu-action@v2
43+
uses: docker/setup-qemu-action@v2.1.0
4344
- name: Set up Docker Buildx
4445
id: buildx
45-
uses: docker/setup-buildx-action@v2
46+
uses: docker/setup-buildx-action@v2.2.1
4647
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
4748
env:
4849
HEAD_REF: ${{github.head_ref}}
4950
if: ${{ github.event_name == 'pull_request' }}
5051
- run: echo 'TAG_NAME=${{ github.event.release.tag_name }}' >> "$GITHUB_ENV"
5152
if: ${{ github.event_name == 'release' }}
52-
- run: echo "REPOSITORY=${{github.repository}}" >> "${GITHUB_ENV}"
5353
- name: Build and push (build)
5454
uses: docker/bake-action@v2.3.0
5555
env:
@@ -97,6 +97,10 @@ jobs:
9797
with:
9898
push: true
9999
files: docker-compose.yml,dev.docker-compose.yml
100+
- name: Start docker
101+
env:
102+
DOCKER_CONTENT_TRUST: 1
103+
run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/deploy_docker_image/test.sh"
100104

101105
# .python-version をDockerイメージと同期させる
102106
update-version-python-version:
@@ -106,74 +110,34 @@ jobs:
106110
pull-requests: write
107111
env:
108112
DOCKER_CONTENT_TRUST: 1
113+
REPOSITORY: ${{github.repository}}
109114
needs: deploy_docker_image
110115
if: always() && (needs.deploy_docker_image.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed'))
111116
steps:
112117
- uses: actions/checkout@v3.1.0
113118
with:
114119
fetch-depth: 0
115120
ref: ${{ github.event.pull_request.head.sha }}
116-
- name: Set .env
117-
run: cp .env.example .env
118-
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
119-
env:
120-
HEAD_REF: ${{github.head_ref}}
121-
- run: echo "REPOSITORY=${{github.repository}}" >> "${GITHUB_ENV}"
122-
- run: docker compose pull
123121
- name: Get Python version
124122
id: get_python_version
125-
run: |
126-
DOCKER_CMD="python --version 2>&1 | sed -e 's/^Python //g'"
127-
python_version=$(docker compose run hato-bot sh -c "${DOCKER_CMD}")
128-
echo "Python version:" "${python_version}"
129-
echo "python_version=${python_version}" >> "${GITHUB_OUTPUT}"
130-
- name: Update versions
131-
run: |
132-
PYTHON_VERSION="${{steps.get_python_version.outputs.python_version}}"
133-
echo "${PYTHON_VERSION}" > .python-version
134-
- uses: dev-hato/actions-diff-pr-management@v1.0.6
123+
run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/update_version_python_version/get_python_version.sh"
124+
env:
125+
HEAD_REF: ${{github.head_ref}}
126+
- uses: dev-hato/actions-diff-pr-management@v1.1.0
135127
with:
136128
github-token: ${{secrets.GITHUB_TOKEN}}
137129
branch-name-prefix: fix-version-python-version
138130
pr-title-prefix: .python-versionを直してあげたよ!
139131
repo-name: dev-hato/hato-bot
140132

141-
pr-docker:
142-
runs-on: ubuntu-latest
143-
env:
144-
DOCKER_CONTENT_TRUST: 1
145-
needs: deploy_docker_image
146-
steps:
147-
- uses: actions/checkout@v3.1.0
148-
with:
149-
fetch-depth: 0
150-
- name: Set .env
151-
run: cp .env.example .env
152-
- name: Login to GitHub Container Registry
153-
uses: docker/login-action@v2
154-
with:
155-
registry: ghcr.io
156-
username: ${{ github.actor }}
157-
password: ${{ secrets.GITHUB_TOKEN }}
158-
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
159-
env:
160-
HEAD_REF: ${{github.head_ref}}
161-
- run: echo "REPOSITORY=${{github.repository}}" >> "${GITHUB_ENV}"
162-
- run: docker compose pull
163-
- name: Start docker
164-
run: docker compose up -d --wait
165-
# Dockerコンテナに疎通できるかテストする
166-
- name: Test
167-
run: curl http://localhost:3000/status
168-
169133
update-dockle:
170134
runs-on: ubuntu-latest
171135
steps:
172136
- uses: actions/checkout@v3.1.0
173137
with:
174138
fetch-depth: 0
175139
ref: ${{ github.event.pull_request.head.sha }}
176-
- uses: dev-hato/actions-update-dockle@v0.0.23
140+
- uses: dev-hato/actions-update-dockle@v0.0.31
177141
with:
178142
github-token: ${{secrets.GITHUB_TOKEN}}
179143
repo-name: dev-hato/hato-bot
@@ -185,43 +149,26 @@ jobs:
185149
- deploy_docker_image
186150
env:
187151
DOCKER_CONTENT_TRUST: 1
152+
REPOSITORY: ${{github.repository}}
188153
steps:
189154
- uses: actions/checkout@v3.1.0
190-
- name: Set .env
191-
run: cp .env.example .env
192-
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
155+
- run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/dockle/run_dockle.sh"
193156
env:
194157
HEAD_REF: ${{github.head_ref}}
195-
- run: echo "REPOSITORY=${{github.repository}}" >> "${GITHUB_ENV}"
196-
- run: |
197-
dockle_version="$(cat .dockle-version)"
198-
curl -L -o dockle.deb "https://github.com/goodwithtech/dockle/releases/download/v${dockle_version}/dockle_${dockle_version}_Linux-64bit.deb"
199-
sudo dpkg -i dockle.deb
200-
- run: docker compose pull
201-
- run: docker compose up -d
202-
- run: |
203-
for image_name in $(docker compose images | awk 'OFS=":" {print $2,$3}' | tail -n +2); do
204-
cmd="dockle --exit-code 1 "
205-
206-
if [[ "${image_name}" =~ "postgres" ]]; then
207-
cmd+="-ak key "
208-
fi
209-
210-
cmd+="${image_name}"
211-
echo "> ${cmd}"
212-
eval "${cmd}"
213-
done
214158

215159
deploy-complete:
216160
runs-on: ubuntu-latest
217161
if: always()
218162
needs:
219163
- update-version-python-version
220-
- pr-docker
221164
- update-dockle
222165
- dockle
223166
steps:
224-
- if: needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-python-version.result == 'success' && (github.event.action == 'closed' || (needs.pr-docker.result == 'success' && needs.dockle.result == 'success'))))
167+
- if: needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-python-version.result == 'success' && (github.event.action == 'closed' || needs.dockle.result == 'success')))
225168
run: exit 0
226-
- if: ${{ !(needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-python-version.result == 'success' && (github.event.action == 'closed' || (needs.pr-docker.result == 'success' && needs.dockle.result == 'success'))))) }}
169+
- if: ${{ !(needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-python-version.result == 'success' && (github.event.action == 'closed' || needs.dockle.result == 'success')))) }}
227170
run: exit 1
171+
172+
concurrency:
173+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
174+
cancel-in-progress: true

.github/workflows/format-json-yml.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424
ref: ${{ github.event.pull_request.head.sha }}
25-
- uses: dev-hato/actions-format-json-yml@v0.0.16
25+
- uses: dev-hato/actions-format-json-yml@v0.0.25
2626
with:
2727
github-token: ${{secrets.GITHUB_TOKEN}}
2828
repo-name: dev-hato/hato-bot
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
31+
cancel-in-progress: true

.github/workflows/pr-check-npm.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,13 @@ jobs:
2525
with:
2626
fetch-depth: 0
2727
ref: ${{ github.event.pull_request.head.sha }}
28-
- name: Get Dependabot npm version
29-
id: get_dependabot_npm_version
30-
run: |
31-
DOCKER_CMD="npm --version"
32-
npm_version="$(docker run ghcr.io/dependabot/dependabot-core sh -c "${DOCKER_CMD}")"
33-
echo "npm version:" "${npm_version}"
34-
echo "npm_version=${npm_version}" >> "${GITHUB_OUTPUT}"
35-
- name: Update version
36-
run: |
37-
DEPENDABOT_NPM_VERSION="${{steps.get_dependabot_npm_version.outputs.npm_version}}"
38-
NPM_PATTERN_PACKAGE="s/\"npm\": \".*\"/\"npm\": \"^${DEPENDABOT_NPM_VERSION}\"/g"
39-
sed -i -e "${NPM_PATTERN_PACKAGE}" package.json
4028
- uses: actions/setup-node@v3.5.1
4129
with:
4230
cache: npm
43-
- run: |
44-
npm_version=$(jq -r '.engines.npm | ltrimstr("^")' package.json)
45-
npm install --prefer-offline --location=global "npm@${npm_version}"
46-
npm install
47-
- uses: dev-hato/actions-diff-pr-management@v1.0.6
31+
- name: Get Dependabot npm version
32+
id: get_dependabot_npm_version
33+
run: bash "${GITHUB_WORKSPACE}/scripts/pr_check_npm/pr_update_version/get_dependabot_npm_version.sh"
34+
- uses: dev-hato/actions-diff-pr-management@v1.1.0
4835
with:
4936
github-token: ${{secrets.GITHUB_TOKEN}}
5037
branch-name-prefix: fix-version
@@ -61,16 +48,13 @@ jobs:
6148
# submodule: 'recursive'
6249
fetch-depth: 0
6350
ref: ${{ github.event.pull_request.head.sha }}
64-
- name: Set up Node.js ${{ env.NODE_VERSION }}
51+
- name: Set up Node.js
6552
uses: actions/setup-node@v3.5.1
6653
with:
6754
cache: npm
6855
- name: Install dependencies
69-
run: |
70-
npm_version=$(jq -r '.engines.npm | ltrimstr("^")' package.json)
71-
npm install --prefer-offline --location=global "npm@${npm_version}"
72-
npm install
73-
- uses: dev-hato/actions-diff-pr-management@v1.0.6
56+
run: bash "${GITHUB_WORKSPACE}/scripts/pr_check_npm/npm_install.sh"
57+
- uses: dev-hato/actions-diff-pr-management@v1.1.0
7458
with:
7559
github-token: ${{secrets.GITHUB_TOKEN}}
7660
branch-name-prefix: npm
@@ -85,3 +69,6 @@ jobs:
8569
run: exit 0
8670
- if: needs.pr-check-npm.result != 'success'
8771
run: exit 1
72+
concurrency:
73+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
74+
cancel-in-progress: true

.github/workflows/pr-copy-ci-hato-bot.yml

Lines changed: 12 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -30,76 +30,26 @@ jobs:
3030
repository: ${{steps.set_org_name.outputs.result}}/sudden-death
3131
path: sudden-death
3232
- name: Copy CI
33-
run: |
34-
worklows_path=.github/workflows
35-
find sudden-death/${worklows_path} -type f \
36-
-not -name "*sudden-death.yml" \
37-
-exec rm -f {} \;
38-
39-
for f in $(find hato-bot/${worklows_path} -type f \
40-
-not -name "*hato-bot.yml" | sed -e "s:hato-bot/${worklows_path}/::g"); do
41-
yq '(.jobs.*.steps.[] | select(has("with")).with | select(has("repo-name")).repo-name) = "dev-hato/sudden-death"' "hato-bot/${worklows_path}/${f}" > "sudden-death/${worklows_path}/${f}"
42-
done
43-
44-
for f in .markdown-lint.yml .python-lint .textlintrc .gitleaks.toml .mypy.ini .pre-commit-config.yaml .python-version .pep8 .flake8 .python-black .isort.cfg renovate.json
45-
do
46-
cp hato-bot/${f} sudden-death/
47-
done
48-
PATTERN_BEFORE="$(grep '^click' sudden-death/Pipfile)"
49-
PATTERN_AFTER="$(grep '^click' hato-bot/Pipfile)"
50-
PATTERN="s/${PATTERN_BEFORE}/${PATTERN_AFTER}/g"
51-
sed -i -e "${PATTERN}" sudden-death/Pipfile
33+
run: bash "${GITHUB_WORKSPACE}/hato-bot/scripts/pr_copy_ci_hato_bot/pr_copy_ci/copy_ci.sh"
5234
- name: Copy package.json
5335
uses: actions/github-script@v6.3.3
5436
with:
5537
github-token: ${{secrets.GITHUB_TOKEN}}
5638
script: |
57-
const fs = require('fs');
58-
const hatoBotPackage = require('./hato-bot/package.json');
59-
const hatoBotPackageLock = require('./hato-bot/package-lock.json');
60-
const suddenDeathPackage = require('./sudden-death/package.json');
61-
const suddenDeathPackageLock = require('./sudden-death/package-lock.json');
62-
63-
delete hatoBotPackage.scripts;
64-
65-
for (const packageKey of Object.keys(hatoBotPackage)) {
66-
suddenDeathPackage[packageKey] = hatoBotPackage[packageKey];
67-
}
68-
69-
fs.writeFileSync('./sudden-death/package.json', JSON.stringify(suddenDeathPackage, null, " ") + "\n", 'utf8');
70-
71-
delete hatoBotPackageLock.name;
72-
73-
for (const packageLockKey of Object.keys(hatoBotPackageLock)) {
74-
suddenDeathPackageLock[packageLockKey] = hatoBotPackageLock[packageLockKey];
75-
}
76-
77-
fs.writeFileSync('./sudden-death/package-lock.json', JSON.stringify(suddenDeathPackageLock, null, " ") + "\n", 'utf8');
39+
const script = require(`${process.env.GITHUB_WORKSPACE}/hato-bot/scripts/pr_copy_ci_hato_bot/pr_copy_ci/copy_package.js`)
40+
script()
7841
- name: Show diff
7942
id: show_diff
8043
working-directory: sudden-death
81-
run: |
82-
git add -A
83-
result="$(git diff --cached)"
84-
result="${result//'%'/'%25'}"
85-
result="${result//$'\n'/'%0A'}"
86-
result="${result//$'\r'/'%0D'}"
87-
echo "diff=${result}" >> "${GITHUB_OUTPUT}"
44+
run: bash "${GITHUB_WORKSPACE}/hato-bot/scripts/pr_copy_ci_hato_bot/pr_copy_ci/show_diff.sh"
8845
- name: Push
8946
if: ${{ steps.show_diff.outputs.diff != '' }}
9047
working-directory: sudden-death
91-
run: |
92-
git config user.name "github-actions[bot]"
93-
EMAIL="41898282+github-actions[bot]@users.noreply.github.com"
94-
git config user.email "${EMAIL}"
95-
git commit -m "鳩は唐揚げ!(hato-botのCIを反映するよ!)"
96-
echo "${{secrets.SUDDEN_DEATH_CI_PRIVATE_KEY}}" > deploy_key.pem
97-
chmod 600 deploy_key.pem
98-
REPO_URL="git@github.com:${{steps.set_org_name.outputs.result}}/sudden-death.git"
99-
GITHUB_HEAD="HEAD:refs/heads/pr-copy-ci"
100-
GIT_SSH_COMMAND="ssh"
101-
GIT_SSH_COMMAND+=" -i deploy_key.pem"
102-
GIT_SSH_COMMAND+=" -o StrictHostKeyChecking=no"
103-
GIT_SSH_COMMAND+=" -F /dev/null"
104-
export GIT_SSH_COMMAND
105-
git push -f "${REPO_URL}" "${GITHUB_HEAD}"
48+
env:
49+
SUDDEN_DEATH_CI_PRIVATE_KEY: ${{secrets.SUDDEN_DEATH_CI_PRIVATE_KEY}}
50+
ORG_NAME: ${{steps.set_org_name.outputs.result}}
51+
run: bash "${GITHUB_WORKSPACE}/hato-bot/scripts/pr_copy_ci_hato_bot/pr_copy_ci/push.sh"
52+
53+
concurrency:
54+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
55+
cancel-in-progress: true

0 commit comments

Comments
 (0)