"nameを追加" #21
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
name: backend | |
on: | |
push: | |
paths: | |
- "src/backend/**" | |
- ".github/workflows/backend.yml" | |
branches: | |
- "main" | |
- "develop" | |
- "feature/*" | |
jobs: | |
set-environment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set environment | |
id: set_environment | |
run: | | |
if [[ ${{ github.ref }} == "refs/heads/main" ]]; then | |
echo "environment=prod" >> $GITHUB_OUTPUT | |
elif [[ ${{ github.ref }} == "refs/heads/develop" || ${{ github.ref }} =~ ^refs/heads/feature/#[0-9]*$ ]]; then | |
echo "environment=dev" >> $GITHUB_OUTPUT | |
else | |
echo "environment=unknown" >> $GITHUB_OUTPUT | |
fi | |
outputs: | |
environment: ${{ steps.set_environment.outputs.environment }} | |
backend: | |
needs: set-environment | |
runs-on: ubuntu-latest | |
environment: ${{ needs.set-environment.outputs.environment }} | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Display Environment Variables | |
run: | | |
echo ${{ secrets.AWS_REGION }} | |
echo ${{ secrets.AWS_ACCOUNT }} | |
echo ${{ secrets.ACTIONS_ROLE}} | |
echo ${{ needs.set_environment.outputs.environment }} | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Setup Node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "20.x" | |
- name: Setup dependencies | |
run: npm ci | |
working-directory: src/backend | |
- name: Build | |
run: npm run build | |
working-directory: src/backend | |
- name: Setup configure-aws-credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: "${{ secrets.AWS_REGION }}" | |
role-to-assume: "arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/${{ secrets.ACTIONS_ROLE }}" | |
- name: CDK Deploy | |
env: | |
ENVIRONMET: ${{ needs.set-environment.outputs.environment }} | |
run: npm run cdk:deploy --context environment=$ENVIRONMENT --require-approval never | |
working-directory: src/backend |