release.yaml test #152
Workflow file for this run
This file contains 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
# node_version: 20, 22とenvironment_type: development, staging, productionの計6パターンでテストを実行 | |
name: run-jest | |
on: | |
push: | |
paths: | |
- "src/**.tsx" | |
- "src/**.ts" | |
- "public/**.html" | |
- ".github/workflows/react-jest.yaml" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
frontend-jest: # job id(typed by user) | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
# デフォルトのワーキングディレクトリのため設定不要だが,明示的に指定。 | |
defaults: | |
run: | |
working-directory: /home/runner/work/devsecops-demo-aws-ecs/devsecops-demo-aws-ecs | |
strategy: | |
matrix: | |
node_version: [20, 22] | |
environment_type: ["development", "staging", "production"] | |
environment: | |
name: ${{ matrix.environment_type }} | |
steps: | |
# checkout repository to runner | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: set up node | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
with: | |
node-version: ${{ matrix.node_version }} | |
- name: install package using aqua | |
uses: aquaproj/aqua-installer@6ce1f8848ec8e61f14d57bd5d7597057a6dd187c # v3.0.1 | |
with: | |
aqua_version: v2.29.0 | |
- name: install dependencies | |
run: github-comment exec --token ${{ secrets.token }} -- npm install | |
# 3環境まとめてテスト | |
- name: run npm run test | |
env: | |
GH_TOKEN: ${{ secrets.token }} # gh用 | |
run: | | |
if [ ${{ matrix.environment_type }} = "development" ]; then | |
npm_type="dev" | |
elif [ ${{ matrix.environment_type }} = "staging" ]; then | |
npm_type="stg" | |
elif [ ${{ matrix.environment_type }} = "production" ]; then | |
npm_type="prod" | |
else | |
echo "invalid environment_type" | |
exit 1 | |
fi | |
# environmentにあった名称でenv_fileを作成し,github actions environment variableを書き込み | |
# NOTE: env_fileはgitで管理したくないため,workflow実行時に作成している。 | |
env_file=".env.${{ matrix.environment_type }}" | |
touch $env_file | |
cat <<EOF >> $env_file | |
$(gh variable list --env ${{ matrix.environment_type }} | awk '{print $1"="$2}') | |
EOF | |
echo ----[DEBUG]: CHECK $env_file---- | |
cat .env.${{ matrix.environment_type }} | |
echo ----[DEBUG]: END---- | |
github-comment exec --token ${{ secrets.token }} -- npm run test-$npm_type -- --watchall=false |