Skip to content

Commit

Permalink
npmのバージョン指定修正時にhato-botのバージョンも考慮する
Browse files Browse the repository at this point in the history
  • Loading branch information
massongit committed May 28, 2024
1 parent 965ad90 commit 24da8ef
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 92 deletions.
60 changes: 58 additions & 2 deletions .github/workflows/deploy-hato-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,61 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: fix-version-python-version
pr-title-prefix: .python-versionを直してあげたよ!
pr-update-version:
runs-on: ubuntu-latest
needs: deploy_docker_image
if: always() && (needs.deploy_docker_image.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed'))
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
cache: npm
node-version-file: package.json
- name: Get npm version
id: get_npm_version
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/pr_update_version/get_npm_version_.sh"
env:
HEAD_REF: ${{github.head_ref || github.event.release.tag_name}}
- uses: dev-hato/actions-diff-pr-management@128afc4203b4e391e03868be91c987b2ddba7ea5 # v1.1.12
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: fix-version
pr-title-prefix: nodeをアップデートしてあげたよ!
# package.jsonに差分があれば、package.jsonからpackage-lock.jsonを作り出す
pr-check-npm:
runs-on: ubuntu-latest
needs: pr-update-version
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
# ここでsubmodule持ってくるとdetached headにcommitして死ぬ
# submodule: 'recursive'
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
cache: npm
node-version-file: package.json
- name: Install dependencies
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/npm_install.sh"
- uses: dev-hato/actions-diff-pr-management@128afc4203b4e391e03868be91c987b2ddba7ea5 # v1.1.12
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: npm
pr-title-prefix: package.jsonやpackage-lock.jsonが更新されたので直してあげたよ!
update-dockle:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -156,12 +211,13 @@ jobs:
if: always()
needs:
- update-version-python-version
- pr-check-npm
- update-dockle
- dockle
steps:
- 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')))
- 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' && needs.pr-check-npm.result == 'success' && (github.event.action == 'closed' || needs.dockle.result == 'success')))
run: exit 0
- 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')))) }}
- 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' && needs.pr-check-npm.result == 'success' && (github.event.action == 'closed' || needs.dockle.result == 'success')))) }}
run: exit 1
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
Expand Down
80 changes: 0 additions & 80 deletions .github/workflows/pr-check-npm.yml

This file was deleted.

File renamed without changes.
15 changes: 15 additions & 0 deletions scripts/deploy_hato_bot/pr_update_version/get_npm_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

DOCKER_CMD="npm --version"
DEPENDABOT_NPM_VERSION="$(docker run ghcr.io/dependabot/dependabot-core sh -c "${DOCKER_CMD}")"
echo "Dependabot npm version:" "${DEPENDABOT_NPM_VERSION}"
RENOVATE_NPM_VERSION="$(docker run ghcr.io/renovatebot/renovate sh -c "${DOCKER_CMD}")"
echo "Renovate npm version:" "${RENOVATE_NPM_VERSION}"
cp .env.example .env
export TAG_NAME="${HEAD_REF//\//-}"
docker compose pull
HATO_BOT_NPM_VERSION="$(docker compose run hato-bot sh -c "${DOCKER_CMD}")"
echo "hato-bot npm version:" "${HATO_BOT_NPM_VERSION}"
NPM_PATTERN_PACKAGE="s/\"npm\": \".*\"/\"npm\": \"^${HATO_BOT_NPM_VERSION} || ^${RENOVATE_NPM_VERSION} || ^${DEPENDABOT_NPM_VERSION}\"/g"
sed -i -e "${NPM_PATTERN_PACKAGE}" package.json
bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/npm_install.sh"
10 changes: 0 additions & 10 deletions scripts/pr_check_npm/pr_update_version/get_npm_version.sh

This file was deleted.

0 comments on commit 24da8ef

Please sign in to comment.