Skip to content

feat: deploying resources to AWS via GH actions #1

feat: deploying resources to AWS via GH actions

feat: deploying resources to AWS via GH actions #1

name: example dir `deployment-with-github-actions` deployment
on:
push:
branches:
- main # run the workflow when a push is made to the main branch
paths:
- deployment-with-github-actions
pull_request:
branches:
- main # run the workflow when the target branch of the PR is main
paths:
- deployment-with-github-actions
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
defaults:
run:
working-directory: ./deployment-with-github-actions
env:
AWS_REGION : 'eu-west-2'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Unit test
run: npm run test
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v4
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 18
run: node -v
- name: Install dependencies
run: npm ci
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::552686430014:role/github-actions-ci-cd-deployment-role
role-session-name: github-action-sls-examples
aws-region: ${{ env.AWS_REGION }}
- name: versions
run: |
pwd
node -v
aws --version
sls --version
- name: deploy
run: npm run deploy:dev