Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

✨ GitHub Actionsでterraform fmtを実行してコミットする #25

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0ad38ea
:sparkles: GitHub Actionsでterraform fmtを実行してコミットする
ikura-hamu Jul 4, 2024
30f04e4
:construction: fmtでdiffが生じる変更
ikura-hamu Jul 4, 2024
6db6662
:sparkles: traO Judgeのチームを作成 (#24)
ikura-hamu Jul 4, 2024
57fe461
:bug: push時にブランチを指定するように
ikura-hamu Jul 4, 2024
59ecfd0
:bug: fetch-depth: 0を追加
ikura-hamu Jul 4, 2024
9ed32d9
Merge 59ecfd0aae462f4828b819fe175b77445039c89f into 6db6662eb07c2f364…
ikura-hamu Jul 4, 2024
e010dbc
[CI] terraform fmt
github-actions[bot] Jul 4, 2024
54c3c2f
:adhesive_bandage: validateとplanはfmtが終わってから実行するように修正
ikura-hamu Jul 4, 2024
915f7c1
:construction: fmtでdiffが生じるような変更
ikura-hamu Jul 4, 2024
c3471a8
Merge 915f7c12b00950b58e987f67bc09d4b7b6799ccc into 6db6662eb07c2f364…
ikura-hamu Jul 4, 2024
5585159
[CI] terraform fmt
github-actions[bot] Jul 4, 2024
800517c
:adhesive_bandage: checkoutするブランチ指定
ikura-hamu Jul 4, 2024
8119283
[CI] terraform fmt
github-actions[bot] Jul 4, 2024
4bcc53d
:adhesive_bandage: 再帰的にワークフローを呼ぶ
ikura-hamu Jul 4, 2024
b883841
:bug: difが無い時はいろいろスキップする
ikura-hamu Jul 4, 2024
2fc907d
:construction: fmtでdiffが出るような変更
ikura-hamu Jul 4, 2024
977442a
[CI] terraform fmt
github-actions[bot] Jul 4, 2024
88ceb35
:adhesive_bandage: 他のワークフロー呼び出し諦める
ikura-hamu Jul 4, 2024
31a78ff
:recycle: 標準じゃない`test == `をやめて`test -z`にする
ikura-hamu Jul 7, 2024
809f8b9
:recycle: needs: "fmt" -> needs: ["fmt"]
ikura-hamu Jul 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main
workflow_dispatch:
workflow_call:
secrets:
GOOGLE_BACKEND_CREDENTIALS:
required: true

permissions:
pull-requests: write
Expand All @@ -18,6 +22,7 @@ env:

jobs:
validate:
needs: ["fmt"]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -38,19 +43,41 @@ jobs:

fmt:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}

- name: Terraform fmt
run: terraform fmt -check -diff -recursive .
id: fmt
run: terraform fmt -diff -no-color -recursive .

- name: Exit if trigger is workflow_dispatch and fmt failed # workflow_dispatchからの実行ではコミットしない
if: github.event_name == 'workflow_dispatch'
env:
TF_FMT_OUTPUT: ${{ steps.fmt.outputs.stdout }}
run: test -z "$TF_FMT_OUTPUT"

- name: Commit changes
if: steps.fmt.outputs.stdout != ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これ息してる?それとも上のtestの部分が働いてない?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

息してると思うけど、どの辺が息してなかった?

想定してる挙動は、

  • workflow_dispatchでfmtにdiffがあったら異常終了
  • workflow_dispatchでfmtにdiffが無かったら何もせず正常終了
  • PRでfmtにdiffが無かったら何もせず正常終了
  • PRでfmtにdiffがあったらコミット

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifのところ、testとやりたいこと同じじゃない?という意味でした

run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m '[CI] terraform fmt'
git push origin HEAD:${{ github.event.pull_request.head.ref }}

plan:
needs: ["fmt"]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
6 changes: 6 additions & 0 deletions members.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ locals {
"ayanakm", # ayana
"beferia", # beferia
"blancnoir256", # BN256
"cho3881392697", # cho
"cobalt1024", # cobalt
"comavius", # comavius
"cp-20", # cp20
"dye8128", # Dye
"emura0", # emura
"eran1515", # Eran
"eyerust", # michadaniel
"Eraxyso", # Eraxyso
"ErrorSyntax1", # SyntaxError
"eyemono-moe", # d_etteiu8383
"Futadaruma", # Futadaruma
Expand Down Expand Up @@ -82,13 +84,15 @@ locals {
"oER4", # o_ER4
"ogu-kazemiya", # ogu_kazemiya
"oribe1115", # oribe
"parahailob", # malfisto
"penguin23-001", # penguin23
"Pentakon26", # Pentakon
"pikachu0310", # pikachu
"pippi0057", # pippi0057
"pirosiki197", # pirosiki
"PL-38", # PL-38
"Propromp", # matsun
"PonponJuice", # Ponjuice
"Pugma", # Pugma
"ramdos0207", # ramdos
"ras0q", # Ras
Expand All @@ -104,6 +108,7 @@ locals {
"Series-205", # Series_205
"sh0go07", # shogotin
"shibutomo", # Mozuya
"shobonvip", # shobon
"shushuya0210", # eru_o2lo
"shota973", # shota_s
"Silent-Clubstep", # shunapo
Expand Down Expand Up @@ -135,6 +140,7 @@ locals {
"ynta-3", # Hokaze
"yuchi-cpu", # u
"YuHima03", # tidus
"yuiveslkao", # Naru820
"Yuki-Ots", # Umin
"yukikurage", # yukikurage
"zer0-star", # zer0-star
Expand Down
10 changes: 10 additions & 0 deletions teams.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,15 @@ locals {
maintainers = ["ras0q"]
description = "2021春ハッカソン"
}

"traOJudge" = {
maintainers = ["kenken714"]
members = [
"cho3881392697", "comavius", "dye8128", "Eraxyso", "ErrorSyntax1", "hayatroid", "Kaki256",
"kisepichu", "mathsuky", "noya2ruler", "ogu-kazemiya", "parahailob", "PonponJuice",
"Pugma", "ramdos0207", "Sotatsu57", "YuHima03", "yuiveslkao", "zer0-star", "ZOI-dayo", "shobonvip",
]
description = "traO Judge"
}
}
}