Skip to content

CI/CD for main / [push] [eaf7f5e1b44c2f1f2b7ac3ede84a6622d761bf1b] #58

CI/CD for main / [push] [eaf7f5e1b44c2f1f2b7ac3ede84a6622d761bf1b]

CI/CD for main / [push] [eaf7f5e1b44c2f1f2b7ac3ede84a6622d761bf1b] #58

Workflow file for this run

name: CI/CD
run-name: '${{ github.workflow }} for ${{ github.ref_name }} / ${{ inputs.environment }} [${{ github.event_name }}] [${{ github.sha }}]'
on:
pull_request:
branches:
- main
paths:
- 'src/**'
- '*.ts'
- '*.cjs'
- 'tsconfig.json'
- 'package.json'
- '.github/workflows/cicd.yml'
push:
branches:
- main
paths:
- 'src/**'
- '*.ts'
- '*.cjs'
- 'tsconfig.json'
- 'package.json'
- '.github/workflows/cicd.yml'
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy'
type: environment
required: true
default: 'prod'
s3-dryrun:
description: 'Dryrun for S3 sync'
type: boolean
required: false
default: false
jobs:
lint:
if: github.event_name == 'pull_request' || github.event_name == 'push'
uses: gawaooooo-sandbox/learn-github-actions-reusable-workflows/.github/workflows/lint.yml@v3
with:
npm-install-options: '--ignore-scripts'
enable-format-check: true
enable-type-check: true
typecheck-script: 'npm run type:check'
permissions:
contents: read
packages: read
test:
if: github.event_name == 'pull_request' || github.event_name == 'push'
uses: ./.github/workflows/test.yml
setup-deployment-config:
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-22.04
timeout-minutes: 5
environment: ${{ github.event_name == 'pull_request' && 'alpha' || inputs.environment }}
outputs:
build-environments: ${{ steps.set-output.outputs.build-environments }}
s3-sync-command: ${{ steps.set-output.outputs.s3-sync-command }}
steps:
- name: Set outputs
id: set-output
uses: gawaooooo-sandbox/learn-github-actions-custom/composite/setup-deployment-config@v3
with:
build-environments: >-
BASE_URL="${{ vars.BASE_URL }}"
TEST_HOGE="${{ vars.TEST_HOGE }}"
s3-sync-command: ./dist ${{ vars.S3_URI }} --delete --dryrun --exclude "*.map" --exclude "test/*.html"
merge-and-deploy:
if: github.event_name == 'pull_request'
needs: [lint, test, setup-deployment-config]
uses: gawaooooo-sandbox/learn-github-actions-reusable-workflows/.github/workflows/deploy.yml@v3
with:
environment: alpha
enable-auto-merge: true
auto-merge-target-branch: develop
build-environments: ${{ needs.setup-deployment-config.outputs.build-environments }}
s3-sync-command: ${{ needs.setup-deployment-config.outputs.s3-sync-command }}
enable-aws-deploy: false
secrets:
node-auth-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
permissions:
contents: write
packages: read
id-token: write
manual-deploy:
if: github.event_name == 'workflow_dispatch'
needs: [setup-deployment-config]
uses: gawaooooo-sandbox/learn-github-actions-reusable-workflows/.github/workflows/deploy.yml@v3
with:
environment: ${{ inputs.environment }}
# enable-auto-merge: false
# checkout-ref: ${{ github.ref }}
build-environments: ${{ needs.setup-deployment-config.outputs.build-environments }}
s3-sync-command: ${{ needs.setup-deployment-config.outputs.s3-sync-command }}
enable-aws-deploy: false
secrets:
node-auth-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
permissions:
contents: write
packages: read
id-token: write