Skip to content

Updated workflow to make starting and stopping with docker compose s… #70

Updated workflow to make starting and stopping with docker compose s…

Updated workflow to make starting and stopping with docker compose s… #70

Workflow file for this run

name: Deploy to Oracle Cloud
on:
push:
branches:
- docker
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/arm64
load: true
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/vow-website:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Summarize the Docker digest
run: |
echo 'Digest: ${{ steps.build-docker.outputs.digest }}'
- name: Copy docker-compose.yml to Oracle Cloud
run: |
echo "${{ secrets.ORACLE_CLOUD_SSH_PRIVATE_KEY }}" > oracle_cloud_key
chmod 600 oracle_cloud_key
scp -i oracle_cloud_key -o StrictHostKeyChecking=no docker-compose.yml ${{ secrets.ORACLE_CLOUD_SSH_USER }}@${{ secrets.ORACLE_CLOUD_IP }}:website/
rm oracle_cloud_key
- name: Deploy to Oracle Cloud
run: |
echo "${{ secrets.ORACLE_CLOUD_SSH_PRIVATE_KEY }}" > oracle_cloud_key
chmod 600 oracle_cloud_key
ssh -i oracle_cloud_key -o StrictHostKeyChecking=no ${{ secrets.ORACLE_CLOUD_SSH_USER }}@${{ secrets.ORACLE_CLOUD_IP }} << EOF
cd website
docker compose down
export DOCKER_IMAGE=${{ secrets.DOCKER_HUB_USERNAME }}/vow-website:latest
export COMPOSE_FILE_DIR=/home/opc/website
docker compose pull
docker compose up -d
docker image prune -f
EOF
rm oracle_cloud_key