Skip to content

Merge pull request #4321 from dev-hato/renovate/sqlfluff-3.x #11840

Merge pull request #4321 from dev-hato/renovate/sqlfluff-3.x

Merge pull request #4321 from dev-hato/renovate/sqlfluff-3.x #11840

---
name: deploy-hato-bot
on:
release:
types:
- published
pull_request:
types:
- opened
- synchronize
- reopened
- closed
push:
branches:
- master
- develop
jobs:
deploy_docker_image:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
REPOSITORY: ${{github.repository}}
permissions:
contents: read
packages: write
if: github.event_name == 'release' || (github.event_name == 'pull_request' && github.event.action != 'closed' && github.repository == github.event.pull_request.head.repo.full_name)
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Set .env
run: cp .env.example .env
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
env:
HEAD_REF: ${{github.head_ref}}
if: ${{ github.event_name == 'pull_request' }}
- run: echo 'TAG_NAME=${{ github.event.release.tag_name }}' >> "$GITHUB_ENV"
if: ${{ github.event_name == 'release' }}
- name: Build and push (build)
uses: docker/bake-action@76cc8060bdff6d632a465001e4cf300684c5472c # v5.7.0
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: build.docker-compose.yml
- name: Build and push (main)
uses: docker/bake-action@76cc8060bdff6d632a465001e4cf300684c5472c # v5.7.0
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml
- name: Build and push (dev)
uses: docker/bake-action@76cc8060bdff6d632a465001e4cf300684c5472c # v5.7.0
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml,dev.base.docker-compose.yml
- run: echo 'TAG_NAME=latest' >> "$GITHUB_ENV"
if: ${{ github.event_name == 'release' }}
- name: Build and push (build) (latest)
uses: docker/bake-action@76cc8060bdff6d632a465001e4cf300684c5472c # v5.7.0
if: ${{ github.event_name == 'release' }}
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: build.docker-compose.yml
- name: Build and push (main) (latest)
uses: docker/bake-action@76cc8060bdff6d632a465001e4cf300684c5472c # v5.7.0
if: ${{ github.event_name == 'release' }}
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml
- name: Build and push (dev) (latest)
uses: docker/bake-action@76cc8060bdff6d632a465001e4cf300684c5472c # v5.7.0
if: ${{ github.event_name == 'release' }}
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml,dev.base.docker-compose.yml
- name: Start docker
env:
DOCKER_CONTENT_TRUST: 1
run: docker compose up -d --wait
# .python-version をDockerイメージと同期させる
update-version-python-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
DOCKER_CONTENT_TRUST: 1
REPOSITORY: ${{github.repository}}
needs: deploy_docker_image
if: always() && (needs.deploy_docker_image.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed'))
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Get Python version
id: get_python_version
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/update_version_python_version/get_python_version.sh"
env:
HEAD_REF: ${{github.head_ref || github.event.release.tag_name}}
- uses: dev-hato/actions-diff-pr-management@7cc8ab103917849f6995064afae9f4cbcfd009ae # v1.1.13
with:
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
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@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
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@7cc8ab103917849f6995064afae9f4cbcfd009ae # v1.1.13
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
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@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
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@7cc8ab103917849f6995064afae9f4cbcfd009ae # v1.1.13
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:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: dev-hato/actions-update-dockle@2c30891ce99130adeaf19aa045cc329fb2f44f48 # v0.0.95
with:
github-token: ${{secrets.GITHUB_TOKEN}}
dockle:
runs-on: ubuntu-latest
needs:
- update-dockle
- deploy_docker_image
env:
DOCKER_CONTENT_TRUST: 1
REPOSITORY: ${{github.repository}}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/dockle/run_dockle.sh"
env:
HEAD_REF: ${{github.head_ref || github.event.release.tag_name}}
deploy-complete:
runs-on: ubuntu-latest
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.pr-check-npm.result == 'success' && 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.pr-check-npm.result == 'success' && needs.dockle.result == 'success'))))) }}
run: exit 1
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true