Skip to content

deploy an example project to the development environment #14

deploy an example project to the development environment

deploy an example project to the development environment #14

name: deploy the selected branch to the development (dev) environment
on:
workflow_dispatch:
inputs:
directory_name:
description: 'project directory name'
required: true
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env:
AWS_REGION : 'eu-west-2'
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.event.inputs.directory_name }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: ${{ github.event.inputs.directory_name }}
- name: Install dependencies
run: npm ci
- name: Unit test
run: npm run test
deploy:
needs: build # This job depends on the build job.
runs-on: ubuntu-latest
environment: development
steps:
- name: Git clone the repository
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
working-directory: ./deployment-with-github-actions
run: npm ci
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
mask-aws-account-id: true
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE_ARN }}
role-session-name: github-action-sls-examples
aws-region: ${{ env.AWS_REGION }}
- name: versions
working-directory: ./deployment-with-github-actions
run: |
echo "printing working directory - $(pwd)"
echo "node version - $(node -v)"
echo "aws cli version - $(aws --version)"
echo "sls version - $(./node_modules/.bin/sls --version)"
- name: deploy
working-directory: ./deployment-with-github-actions
run: npm run deploy:dev