feat: fix content #21
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
name: Docker Image CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
DOCKER_USER: ${{ secrets.DOCKER_USER }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Git Semantic Version | |
uses: PaulHatch/semantic-version@v5.4.0 | |
with: | |
major_pattern: "major: " | |
minor_pattern: "feat: " | |
version_format: "${major}.${minor}.${patch}-prerelease${increment}" | |
id: version | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Docker auth | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ env.DOCKER_USER }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Build and push Docker Image | |
uses: docker/build-push-action@v2 | |
env: | |
NEW_VERSION: ${{ steps.version.outputs.version }} | |
with: | |
context: ./ | |
push: true | |
dockerfile: ./Dockerfile | |
tags: jaderodev/email-service:${{ env.NEW_VERSION }} | |
- name: Build and push Docker Image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
push: true | |
dockerfile: ./Dockerfile | |
tags: jaderodev/email-service:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Docker auth | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ env.DOCKER_USER }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Set permissions for private key | |
run: | | |
echo "${{ secrets.AWS_PRIVATE_KEY }}" > key.pem | |
chmod 600 key.pem | |
- name: Move to project folder | |
run: | | |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@3.228.164.55 'docker_flow.sh backend jaderodev/email-service:latest email-service' | |