Skip to content

Commit c0485f6

Browse files
committed
add pull and run script to workflow
1 parent ccb4d0c commit c0485f6

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

.github/workflows/aws-ui-cd-stage.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ jobs:
3838
run: |
3939
make login publish image_tag=$RELEASE_VERSION
4040
41-
# - name: Setup terraform
42-
# uses: hashicorp/setup-terraform@v1
43-
# with:
44-
# terraform_version: 1.1.9
45-
46-
# - name: Authenticate with the TF modules repository
47-
# uses: webfactory/[email protected]
48-
# with:
49-
# ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}
50-
51-
# - name: Terraform Init
52-
# working-directory: ${{ env.WORKING_DIR }}
53-
# run: terraform init
54-
55-
# - name: Terraform Apply
56-
# working-directory: ${{ env.WORKING_DIR }}
57-
# run: terraform apply -var-file="${{ env.TF_WORKSPACE }}.tfvars" -var "image_tag=$RELEASE_VERSION" -auto-approve
41+
- name: SCP files via ssh key
42+
uses: appleboy/scp-action@master
43+
env:
44+
USERNAME: ${{ secrets.AWS_EC2_USER }}
45+
HOST: ${{ secrets.STAGE_BACKEND_URL }}
46+
KEY: ${{ secrets.STAGE_AWS_PRIVATE_KEY }}
47+
with:
48+
source: './infrastructure/aws_ec2.sh'
49+
target: '.'
50+
51+
- name: Deploy
52+
run: |
53+
TEMP=$(mktemp)
54+
echo "${{ secrets.STAGE_AWS_PRIVATE_KEY }}" > $TEMP
55+
chmod 400 $TEMP
56+
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.STAGE_BACKEND_URL }} "chmod +x ./infrastructure/aws_ec2.sh"
57+
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.STAGE_BACKEND_URL }} "./infrastructure/aws_ec2.sh $RELEASE_VERSION" stage

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ testdev: ## Run all tests on docker container timetracker_ui at the Dev
5050
docker exec timetracker_ui bash -c "npm run ci-test"
5151

5252
.PHONY: publish
53-
publish: require-image_tag-arg ## Upload a docker image to the stage azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
54-
docker tag timetracker_ui:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)
55-
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)
53+
publish: require-environment-arg require-image_tag-arg ## Upload a docker image to the stage azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
54+
docker tag timetracker_ui:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/$(environment)-ui:$(image_tag)
55+
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/$(environment)-ui:$(image_tag)
5656

5757
.PHONY: build_prod
5858
build_prod: ## Create docker image with dependencies needed for production -- to test locally only
@@ -81,8 +81,8 @@ remove_prod: ## Delete container timetracker_ui_prod.
8181

8282
.PHONY: publish_prod
8383
publish_prod: ## Upload a docker image to the prod azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
84-
docker tag timetracker_ui_prod:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)
85-
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)
84+
docker tag timetracker_ui_prod:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/prod-ui:$(image_tag)
85+
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/prod-ui:$(image_tag)
8686

8787
.PHONY: login
8888
login: ## Login in respository of docker images

infrastructure/aws_ec2.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/sh
2+
echo "Deploying $1..."
3+
docker ps -aq | xargs docker stop| xargs docker rm --force --volumes
4+
docker system prune -af
5+
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 568748651446.dkr.ecr.us-east-1.amazonaws.com
6+
docker run -d --name timetracker_api -p 7071:7071 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/$2-ui:$1

0 commit comments

Comments
 (0)