Re- added the copy step #36
Workflow file for this run
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: Deploy to Oracle Cloud | |
on: | |
push: | |
branches: | |
- docker | |
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 | |
- name: Copy application files to Oracle Cloud | |
run: | | |
# Save SSH private key to a file | |
echo "${{ secrets.ORACLE_CLOUD_SSH_PRIVATE_KEY }}" > oracle_cloud_key | |
chmod 600 oracle_cloud_key | |
# Create a temporary directory and copy files to it | |
temp_dir=$(mktemp -d) | |
cp -r * "$temp_dir" | |
# Debugging: List contents of the temporary directory | |
echo "Listing temporary directory contents:" | |
ls -la "$temp_dir" | |
# Copy files from the temporary directory to Oracle Cloud | |
echo "Copying files to Oracle Cloud..." | |
scp -r -i oracle_cloud_key -o StrictHostKeyChecking=no "$temp_dir/"* ${{ secrets.ORACLE_CLOUD_SSH_USER }}@${{ secrets.ORACLE_CLOUD_IP }}:website/ | |
# Clean up the SSH key file and temporary directory | |
rm oracle_cloud_key | |
rm -rf "$temp_dir" | |
- name: Deploy to Oracle Cloud | |
env: | |
OCI_CLI_AUTH: instance_principal | |
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }} | |
DB_USER: ${{ secrets.DB_USER }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
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 | |
echo "$DOCKER_HUB_ACCESS_TOKEN" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin | |
export DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD} | |
export DB_USER=${DB_USER} | |
export DB_PASSWORD=${DB_PASSWORD} | |
export DOCKER_IMAGE=${DOCKER_HUB_USERNAME}/vow-website:latest | |
export COMPOSE_FILE_DIR=/home/opc/website | |
docker compose pull | |
docker compose up -d | |
docker logout | |
EOF | |
rm oracle_cloud_key |