Skip to content

deploy build 2 (only) #26

deploy build 2 (only)

deploy build 2 (only) #26

Workflow file for this run

name: CI/CD OCA
on:
push:
branch: "teste-deploy-aws"
jobs:
# build-1:
# runs-on: [x1-aws-self-hosted-runner, self-hosted]
# steps:
# - uses: actions/checkout@v4
#
# - name: Update docker metadata with the tag
# uses: docker/metadata-action@v4
# id: meta
# with:
# images: ${{ vars.DOCKER_IMAGE_PROD }}
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
#
# - name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ vars.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
#
# - name: Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# context: .
# push: true
# file: Dockerfile.production
# labels: ${{ steps.meta.outputs.labels }}
# tags: |
# ${{ vars.DOCKER_IMAGE_PROD }}:latest
# ${{ steps.meta.outputs.tags }}
# build-args: |
# NEXT_PUBLIC_HOST_URL=${{ vars.NEXT_PUBLIC_HOST_URL }}
# NEXT_PUBLIC_GEE_PRIVATE_KEY=${{ secrets.NEXT_PUBLIC_GEE_PRIVATE_KEY }}
# NEXT_PUBLIC_GA_ID=${{ secrets.NEXT_PUBLIC_GA_ID }}
# NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN=${{ secrets.NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN }}
# NEXT_PUBLIC_CONTENTFUL_SPACE=${{ secrets.NEXT_PUBLIC_CONTENTFUL_SPACE }}
# NEXT_PUBLIC_MAIL_APP_TO=${{ vars.NEXT_PUBLIC_MAIL_APP_TO }}
# NEXT_PUBLIC_MAIL_APP_CC=${{ vars.NEXT_PUBLIC_MAIL_APP_CC }}
# NEXT_PUBLIC_MAIL_APP_USER=${{ vars.NEXT_PUBLIC_MAIL_APP_USER }}
# NEXT_PUBLIC_MAIL_APP_PASS=${{ secrets.NEXT_PUBLIC_MAIL_APP_PASS }}
#
# - name: Pull the latest image
# run: sudo docker pull ${{ vars.DOCKER_IMAGE_PROD }}:latest
#
# - name: Stop existing container
# run: sudo docker rm -f ${{ vars.CONTAINER_NAME_PROD }} || true
#
# - name: Run new container
# run: sudo docker run --name ${{ vars.CONTAINER_NAME_PROD }} -p ${{ vars.HOST_PORT_PROD }}:${{ vars.CONTAINER_PORT }} -d ${{ vars.DOCKER_IMAGE_PROD }}:latest
#
# - name: Adding network to the container
# run: docker network connect oca-network oca-frontend-app
#
# - name: Prune unused Docker images
# run: sudo docker system prune -f
# #
build-2:
runs-on: [x2-aws-self-hosted-runner, self-hosted]
steps:
- uses: actions/checkout@v4
- name: Update docker metadata with the tag
uses: docker/metadata-action@v4
id: meta
with:
images: ${{ vars.DOCKER_IMAGE_PROD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
file: Dockerfile.production
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ vars.DOCKER_IMAGE_PROD }}:latest
${{ steps.meta.outputs.tags }}
build-args: |
NEXT_PUBLIC_HOST_URL=${{ vars.NEXT_PUBLIC_HOST_URL }}
NEXT_PUBLIC_GEE_PRIVATE_KEY=${{ secrets.NEXT_PUBLIC_GEE_PRIVATE_KEY }}
NEXT_PUBLIC_GA_ID=${{ secrets.NEXT_PUBLIC_GA_ID }}
NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN=${{ secrets.NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN }}
NEXT_PUBLIC_CONTENTFUL_SPACE=${{ secrets.NEXT_PUBLIC_CONTENTFUL_SPACE }}
NEXT_PUBLIC_MAIL_APP_TO=${{ vars.NEXT_PUBLIC_MAIL_APP_TO }}
NEXT_PUBLIC_MAIL_APP_CC=${{ vars.NEXT_PUBLIC_MAIL_APP_CC }}
NEXT_PUBLIC_MAIL_APP_USER=${{ vars.NEXT_PUBLIC_MAIL_APP_USER }}
NEXT_PUBLIC_MAIL_APP_PASS=${{ secrets.NEXT_PUBLIC_MAIL_APP_PASS }}
- name: Pull the latest image
run: sudo docker pull ${{ vars.DOCKER_IMAGE_PROD }}:latest
- name: Stop existing container
run: sudo docker rm -f ${{ vars.CONTAINER_NAME_PROD }} || true
- name: Run new container
run: sudo docker run --name ${{ vars.CONTAINER_NAME_PROD }} -p ${{ vars.HOST_PORT_PROD }}:${{ vars.CONTAINER_PORT }} -d ${{ vars.DOCKER_IMAGE_PROD }}:latest
- name: Prune unused Docker images
run: sudo docker system prune -f