リリース #20141
This file contains hidden or 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: deploy-hato-bot | |
| on: | |
| release: | |
| types: | |
| - published | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - closed | |
| branches: | |
| - develop | |
| - master | |
| push: | |
| branches: | |
| - master | |
| - develop | |
| permissions: {} | |
| jobs: | |
| update-uv-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| - name: Get uv version | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/update_uv_version/get_uv_version.sh" | |
| env: | |
| GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| HEAD_REF: ${{github.head_ref || github.event.release.tag_name}} | |
| - uses: dev-hato/actions-diff-pr-management@5cd3792bc98beed11cda90898bc81af6bfa199af # v2.2.5 | |
| with: | |
| github-token: ${{secrets.GITHUB_TOKEN}} | |
| branch-name-prefix: fix-uv-version | |
| pr-title-prefix: uvのバージョンを直してあげたよ! | |
| 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) | |
| needs: update-uv-version | |
| steps: | |
| - name: Start Workflow Telemetry | |
| uses: dev-hato/actions-workflow-metrics@45b554e37e02b7459582c446b17124b31d13a5f7 # v0.0.6 | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set .env | |
| run: cp .env.example .env | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - 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@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0 | |
| env: | |
| DOCKER_CONTENT_TRUST: 1 | |
| with: | |
| push: true | |
| files: build.docker-compose.yml | |
| source: . | |
| - name: Build and push (main) | |
| uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0 | |
| env: | |
| DOCKER_CONTENT_TRUST: 1 | |
| with: | |
| push: true | |
| files: docker-compose.yml | |
| source: . | |
| - name: Build and push (dev) | |
| uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0 | |
| env: | |
| DOCKER_CONTENT_TRUST: 1 | |
| with: | |
| push: true | |
| files: docker-compose.yml,dev.base.docker-compose.yml | |
| source: . | |
| - run: echo 'TAG_NAME=latest' >> "$GITHUB_ENV" | |
| if: ${{ github.event_name == 'release' }} | |
| - name: Build and push (build) (latest) | |
| uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0 | |
| if: ${{ github.event_name == 'release' }} | |
| env: | |
| DOCKER_CONTENT_TRUST: 1 | |
| with: | |
| push: true | |
| files: build.docker-compose.yml | |
| source: . | |
| - name: Build and push (main) (latest) | |
| uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0 | |
| if: ${{ github.event_name == 'release' }} | |
| env: | |
| DOCKER_CONTENT_TRUST: 1 | |
| with: | |
| push: true | |
| files: docker-compose.yml | |
| source: . | |
| - name: Build and push (dev) (latest) | |
| uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0 | |
| if: ${{ github.event_name == 'release' }} | |
| env: | |
| DOCKER_CONTENT_TRUST: 1 | |
| with: | |
| push: true | |
| files: docker-compose.yml,dev.base.docker-compose.yml | |
| source: . | |
| - name: Start docker | |
| env: | |
| DOCKER_CONTENT_TRUST: 1 | |
| run: docker compose up -d --wait | |
| # pyproject.toml をDockerイメージと同期させる | |
| update-version-pyproject: | |
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| - 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@5cd3792bc98beed11cda90898bc81af6bfa199af # v2.2.5 | |
| with: | |
| github-token: ${{secrets.GITHUB_TOKEN}} | |
| branch-name-prefix: fix-version-pyproject | |
| pr-title-prefix: pyproject.tomlを直してあげたよ! | |
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| with: | |
| cache: npm | |
| node-version-file: package.json | |
| - if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| run: npm install -g "$(yq -r '.packageManager' 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@5cd3792bc98beed11cda90898bc81af6bfa199af # v2.2.5 | |
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| 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 }} | |
| persist-credentials: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| with: | |
| cache: npm | |
| node-version-file: package.json | |
| - if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| run: npm install -g "$(yq -r '.packageManager' package.json)" | |
| - name: Install dependencies | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| run: npm install | |
| - uses: dev-hato/actions-diff-pr-management@5cd3792bc98beed11cda90898bc81af6bfa199af # v2.2.5 | |
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: github.event_name != 'pull_request' || github.event.action != 'closed' | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| - uses: dev-hato/actions-update-dockle@a0c71c830be4d9b17009a390afbe13efd55838df # v0.0.137 | |
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - 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-pyproject | |
| - 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-pyproject.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-pyproject.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 |