Skip to content

Commit

Permalink
CI release: pushトリガーで実行されるjobを減らす (#3894)
Browse files Browse the repository at this point in the history
  • Loading branch information
massongit authored Jan 12, 2024
1 parent 2aff985 commit 979c207
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
format-go:
runs-on: ubuntu-latest
needs: docker-compose-build-base
if: always() && (needs.docker-compose-build-base.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed') || github.event_name == 'merge_group')
if: always() && github.event_name != 'push' && (needs.docker-compose-build-base.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed') || github.event_name == 'merge_group')
permissions:
contents: write
pull-requests: write
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
update-package:
runs-on: ubuntu-latest
needs: docker-compose-build-base
if: always() && (needs.docker-compose-build-base.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed') || github.event_name == 'merge_group')
if: always() && github.event_name != 'push' && (needs.docker-compose-build-base.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed') || github.event_name == 'merge_group')
permissions:
contents: write
pull-requests: write
Expand Down Expand Up @@ -250,6 +250,7 @@ jobs:
pr-title-prefix: nodeのバージョンを直してあげたよ!
update-dockle:
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/[email protected]
if: github.event_name != 'pull_request' || github.event.action != 'closed'
Expand All @@ -263,6 +264,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- docker-compose-build
if: github.event_name != 'push'
steps:
- uses: actions/[email protected]
- run: cat .env >>"$GITHUB_ENV"
Expand All @@ -276,6 +278,7 @@ jobs:
needs:
- docker-compose-build
- update-dockle
if: github.event_name != 'push'
strategy:
matrix:
docker_compose_file_name: ["dev.base.compose.yml", "staging.compose.yml"]
Expand Down Expand Up @@ -327,6 +330,7 @@ jobs:
env:
DOCKER_CONTENT_TRUST: 1
REPOSITORY: ${{github.repository}}
if: github.event_name != 'push'
steps:
- uses: actions/[email protected]
- run: cat .env >>"$GITHUB_ENV"
Expand Down Expand Up @@ -361,6 +365,7 @@ jobs:
env:
DOCKER_CONTENT_TRUST: 1
REPOSITORY: ${{github.repository}}
if: github.event_name != 'push'
steps:
- uses: actions/[email protected]
- run: cat .env >>"$GITHUB_ENV"
Expand Down Expand Up @@ -388,6 +393,8 @@ jobs:
needs:
- build-frontend
- e2e-test-mini-docker-compose
- docker-compose-build
- make-browserslist
if: github.event_name == 'push' || github.event_name == 'merge_group' || (github.repository == github.event.pull_request.head.repo.full_name && github.repository == 'dev-hato/hato-atama')
permissions:
id-token: write
Expand Down Expand Up @@ -445,6 +452,7 @@ jobs:
env:
ARTIFACT_PATH: ${{ github.workspace }}/tmp/artifacts
URLS: https://v${{ github.run_number }}-dot-hato-atama.an.r.appspot.com
if: github.event_name != 'push'
steps:
- uses: actions/[email protected]
- run: mkdir -p "${ARTIFACT_PATH}"
Expand Down Expand Up @@ -488,7 +496,6 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 3
needs:
- e2e-test-all-docker-compose
- e2e-test-mini-prd
- make-browserslist
strategy:
Expand Down Expand Up @@ -564,45 +571,38 @@ jobs:
- name: Remove app engine versions
if: ${{ steps.get_run_numbers.outputs.result != '' }}
run: gcloud app versions delete --service=default ${{steps.get_run_numbers.outputs.result}}
# docker-compose関連でPRとpushで共通して必ず完了しているべきjobが完了したか
release-complete-check-docker-compose:
runs-on: ubuntu-latest
needs:
- update-package
- format-go
- check-nginx-config
- dockle
- e2e-test-mini-docker-compose
- e2e-test-all-docker-compose
steps:
- run: exit 0
# PRとpushで共通して完了しているべきjobが完了したか
release-complete-check:
runs-on: ubuntu-latest
if: always() && (github.event_name != 'pull_request' || github.event.action != 'closed')
needs:
- lighthouse
- e2e-test-mini-prd
- check-deploy-diff
- release-complete-check-docker-compose
steps:
- if: (github.repository != 'dev-hato/hato-atama' || needs.check-deploy-diff.outputs.deploy-files == 'false' || (needs.lighthouse.result == 'success' && needs.e2e-test-mini-prd.result == 'success')) && needs.release-complete-check-docker-compose.result == 'success'
- if: (github.repository != 'dev-hato/hato-atama' || needs.check-deploy-diff.outputs.deploy-files == 'false' || needs.e2e-test-mini-prd.result == 'success')
run: exit 0
- if: (github.repository == 'dev-hato/hato-atama' && needs.check-deploy-diff.outputs.deploy-files == 'true' && (needs.lighthouse.result != 'success' || needs.e2e-test-mini-prd.result != 'success')) || needs.release-complete-check-docker-compose.result != 'success'
- if: (github.repository == 'dev-hato/hato-atama' && needs.check-deploy-diff.outputs.deploy-files == 'true' && needs.e2e-test-mini-prd.result != 'success')
run: exit 1
# PRをトリガーとした場合に完了しているべきjobが完了したか
# forkしたリポジトリからdev-hato/hato-atamaへPRを出した場合やforkしたリポジトリ上でPRを立てた場合、merge_groupトリガーの場合はcreate-pr-environmentがskipされていても完了したものと見なす
pr-test-complete:
runs-on: ubuntu-latest
if: always() && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'merge_group')
needs:
- lighthouse
- format-go
- update-package
- dockle
- check-nginx-config
- e2e-test-mini-docker-compose
- e2e-test-all-docker-compose
- release-complete-check
- create-pr-environment
- check-deploy-diff
steps:
- if: needs.release-complete-check.result == 'success' && (github.event_name == 'merge_group' || github.repository != github.event.pull_request.head.repo.full_name || github.repository != 'dev-hato/hato-atama' || needs.check-deploy-diff.outputs.deploy-files == 'false' || needs.create-pr-environment.result == 'success')
- if: needs.release-complete-check.result == 'success' && (github.event_name == 'merge_group' || github.repository != github.event.pull_request.head.repo.full_name || github.repository != 'dev-hato/hato-atama' || needs.check-deploy-diff.outputs.deploy-files == 'false' || (needs.create-pr-environment.result == 'success' && needs.lighthouse.result == 'success' && needs.format-go.result == 'success' && needs.update-package.result == 'success' && needs.dockle.result == 'success' && needs.check-nginx-config.result == 'success' && needs.e2e-test-mini-docker-compose.result == 'success' && needs.e2e-test-all-docker-compose.result == 'success'))
run: exit 0
- if: needs.release-complete-check.result != 'success' || (github.event_name != 'merge_group' && github.repository == github.event.pull_request.head.repo.full_name && github.repository == 'dev-hato/hato-atama' && needs.check-deploy-diff.outputs.deploy-files == 'true' && needs.create-pr-environment.result != 'success')
- if: needs.release-complete-check.result != 'success' || (github.event_name != 'merge_group' && github.repository == github.event.pull_request.head.repo.full_name && github.repository == 'dev-hato/hato-atama' && needs.check-deploy-diff.outputs.deploy-files == 'true' && (needs.create-pr-environment.result != 'success' || needs.lighthouse.result != 'success' || needs.format-go.result != 'success' || needs.update-package.result != 'success' || needs.dockle.result != 'success' || needs.check-nginx-config.result != 'success' || needs.e2e-test-mini-docker-compose.result != 'success' || needs.e2e-test-all-docker-compose.result != 'success'))
run: exit 1
action-timeline-pr-test-complete:
needs: pr-test-complete
Expand Down

0 comments on commit 979c207

Please sign in to comment.