diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..875605f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,28 @@ +name: Deploy to EC2 + +on: + release: + types: + [prereleased, released] + +env: + AWS_REGION: us-east-1 + + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v2 + - uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - run: | + echo "Deploying branch ${{ env.GITHUB_REF }} to ${{ github.event.inputs.environment }}" + commit_hash=`git rev-parse HEAD` + aws deploy create-deployment --application-name ${{ secrets.CODE_DEPLOY_APPLICATION_NAME }} --deployment-group-name ${{ secrets.CODE_DEPLOY_GROUP_NAME }} --github-location repository=$GITHUB_REPOSITORY,commitId=$commit_hash --ignore-application-stop-failures \ No newline at end of file diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 0000000..bfbda04 --- /dev/null +++ b/appspec.yml @@ -0,0 +1,14 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /qss +hooks: + AfterInstall: + - location: aws/scripts/after-install.sh + timeout: 300 + runas: root + ApplicationStart: + - location: aws/scripts/application-start.sh + timeout: 300 + runas: root \ No newline at end of file diff --git a/aws/scripts/after-install.sh b/aws/scripts/after-install.sh new file mode 100644 index 0000000..59a8e22 --- /dev/null +++ b/aws/scripts/after-install.sh @@ -0,0 +1 @@ +npm i \ No newline at end of file diff --git a/aws/scripts/application-start.sh b/aws/scripts/application-start.sh new file mode 100644 index 0000000..a01add9 --- /dev/null +++ b/aws/scripts/application-start.sh @@ -0,0 +1 @@ +npm run start \ No newline at end of file