Update docker-image.yml #63
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/[email protected] | |
with: | |
major_pattern: "major:" | |
minor_pattern: "feat:" | |
version_format: "${major}.${minor}.${patch}-prerelease${increment}" | |
search_commit_body: true | |
change_path: "./" | |
id: version | |
- name: Echo | |
run: | | |
echo ${{ steps.version.outputs.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/aup-backend:${{ env.NEW_VERSION }} | |
# - name: Build and push Docker Image | |
# uses: docker/build-push-action@v2 | |
# with: | |
# context: ./ | |
# push: true | |
# dockerfile: ./Dockerfile | |
# tags: jaderodev/aup-backend: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 [email protected] 'cd backend/ && sudo docker compose down' | |
# - name: Remove old image | |
# run: | | |
# ssh -o StrictHostKeyChecking=no -i key.pem [email protected] 'sudo docker image rm -f backend-aup-backend:latest' | |
# - name: Run new containers | |
# run: | | |
# ssh -o StrictHostKeyChecking=no -i key.pem [email protected] 'cd backend/ && git pull && sudo docker compose up -d' | |