-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
191 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: deploy | ||
|
||
on: push | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
cache: npm | ||
node-version: 16 | ||
- run: npm install | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifact | ||
path: node_modules/ | ||
|
||
deploy-infra: | ||
needs: build | ||
if: github.ref_name == 'hello-world' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: ${{ secrets.IAMROLE_GITHUB }} | ||
role-session-name: GitHub-Action-Role | ||
aws-region: eu-west-1 | ||
- run: | | ||
aws cloudformation deploy \ | ||
--region eu-west-1 \ | ||
--stack-name website \ | ||
--template-file main.yml \ | ||
--no-fail-on-empty-changeset \ | ||
--capabilities CAPABILITY_NAMED_IAM \ | ||
--parameter-overrides \ | ||
EC2InstanceType=t2.micro | ||
deploy: | ||
needs: deploy-infra | ||
if: github.ref_name == 'hello-world' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: | | ||
echo 'hello world' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 0.0 | ||
os: linux | ||
files: | ||
# unzip the build artifact in ~/app | ||
- source: / | ||
destination: /home/ec2-user/app/release | ||
permissions: | ||
# change permissions from root to ec2-user | ||
- object: /home/ec2-user/app/release | ||
pattern: "**" | ||
owner: ec2-user | ||
group: ec2-user | ||
hooks: | ||
ApplicationStart: | ||
# start the application | ||
- location: start.sh | ||
timeout: 300 | ||
runas: ec2-user | ||
ApplicationStop: | ||
# stop the application | ||
- location: stop.sh | ||
timeout: 300 | ||
runas: ec2-user |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
# | ||
|
||
EC2_INSTANCE_TYPE=t2.micro | ||
|
||
echo -e "\n\n=========== Deploying main.yml ===========" | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Reference this: | ||
|
||
https://github.com/aws-samples/aws-codedeploy-github-actions-deployment/blob/main/cloudformation/template.yaml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash -xe | ||
|
||
source /home/ec2-user/.bash_profile | ||
cd /home/ec2-user/app/release | ||
npm run start |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash -xe | ||
|
||
source /home/ec2-user/.bash_profile | ||
[ -d "/home/ec2-user/app/release" ] && \ | ||
cd /home/ec2-user/app/release && \ | ||
npm stop |