-
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
1 changed file
with
18 additions
and
4 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 |
---|---|---|
|
@@ -132,8 +132,22 @@ jobs: | |
needs: [prepare, build-image-push] | ||
if: always() && (needs.build-image-push.result == 'success' && needs.prepare.outputs.deploy == 'true') | ||
steps: | ||
- name: Deploy | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Set permissions for private key | ||
run: | | ||
echo "${{ secrets.AWS_EC2_PRIVATE_KEY }}" > key.pem | ||
chmod 600 key.pem | ||
- name: Pull Docker image | ||
run: | | ||
ssh -o StrictHostKeyChecking=no -i key.pem [email protected] 'sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:${{ needs.prepare.outputs.tag_version }}' | ||
- name: Stop running container | ||
run: | | ||
ssh -o StrictHostKeyChecking=no -i key.pem [email protected] 'sudo docker stop spring-boot-tests-cicd || true' | ||
ssh -o StrictHostKeyChecking=no -i key.pem [email protected] 'sudo docker rm spring-boot-tests-cicd || true' | ||
- name: Run new container | ||
run: | | ||
echo ${{ needs.prepare.outputs.deploy }} | ||
echo ${{ needs.prepare.outputs.deploy == 'true' }} | ||
echo "Deploying the app to ${{ needs.prepare.outputs.environment }} using ${{ github.event.repository.name }}:${{ needs.prepare.outputs.tag_version }} image" | ||
ssh -o StrictHostKeyChecking=no -i key.pem [email protected] 'sudo docker run -d --name spring-boot-tests-cicd -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:${{ needs.prepare.outputs.tag_version }}' |