Skip to content

パーティションインデックスの追加 #145

パーティションインデックスの追加

パーティションインデックスの追加 #145

Workflow file for this run

name: CI
on:
push:
branches:
- feature/**
paths:
- .github/workflows/ci.yml
- environments/**
- modules/**
env:
AWS_ROLE_ARN: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.IAM_ROLE_NAME }}
AWS_DEFAULT_REGION: ap-northeast-1
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
setup:
runs-on: ubuntu-latest
outputs:
modules_changed: ${{ steps.modules_changes.outputs.changes }}
envs_changed: ${{ steps.envs_changes.outputs.changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed modules dirs
uses: dorny/paths-filter@v2
id: modules_changes
with:
filters: |
modules:
- 'modules/**'
- name: Get changed envs dirs
uses: dorny/paths-filter@v2
id: envs_changes
with:
filters: |
environments:
- 'environments/**'
CI:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Aqua
uses: actions/[email protected]
with:
path: ~/.local/share/aquaproj-aqua
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('.aqua/*.yaml')}}
restore-keys: |
v1-aqua-installer-${{runner.os}}-${{runner.arch}}-
- name: Setup Aqua
uses: aquaproj/[email protected]
with:
aqua_version: v2.28.0
aqua_opts: ""
- name: Install tools via Aqua
run: aqua install
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Run TFsec
if: needs.setup.outputs.modules_changed != '[]'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tfsec --format=checkstyle | reviewdog -f=checkstyle -name="tfsec" -reporter=github-pr-review -filter-mode=nofilter -fail-on-error
- name: Run TFlint
if: needs.setup.outputs.modules_changed != '[]'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tflint --init
tflint --format=checkstyle | reviewdog -f=checkstyle -name="tflint" -reporter=github-pr-review -filter-mode=nofilter -fail-on-error
- name: Initialize Terragrunt
working-directory: environments/prod
run: terragrunt run-all init --terragrunt-non-interactive
- name: Check Terragrunt format
working-directory: environments/prod
run: terragrunt run-all fmt -check
- name: Validate Terragrunt
working-directory: environments/prod
run: terragrunt run-all validate
- name: Run Terragrunt plan
working-directory: environments/prod
run: terragrunt run-all plan
release-pull-request:
needs: [setup, CI]
if: needs.setup.outputs.envs_changed != '[]' || needs.setup.outputs.modules_changed != '[]'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set Tokyo Time
id: set_tokyo_time
run: echo "tokyo_time=$(TZ=Asia/Tokyo date '+%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Determine if PR already exists
id: check_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_COUNT=$(gh pr list --head "${{ github.ref_name }}" --json number --jq '. | length')
echo "::set-output name=pr_count::$PR_COUNT"
- name: Create Pull Request
if: steps.check_pr.outputs.pr_count == '0'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tokyo_time=$(TZ=Asia/Tokyo date '+%Y-%m-%d %H:%M:%S')
gh pr create \
-B main \
-H "${{ github.ref_name }}" \
-t "Automated Release - $tokyo_time" \
-b "This automated PR merges the feature branch '${{ github.ref_name }}' into 'main' and includes the following updates:\n\n- Security checks\n- Format checks\n\nPlease review and approve the changes." \
-a "${{ github.actor }}"
shell: bash