From e16f3f8fa9758e0c444cb7999e047e7ede7a572a Mon Sep 17 00:00:00 2001 From: kmaxi <66730396+kmaxii@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:00:02 +0200 Subject: [PATCH] Create cicd.yml --- .github/workflows/cicd.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/cicd.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..6ee397e --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,38 @@ +name: Deploy to Oracle Cloud + +on: + push: + branches: + - docker + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - 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 + run: | + docker buildx build --platform linux/amd64 --push -t ${{ secrets.DOCKER_HUB_USERNAME }}/vow-website:latest . + + - name: Deploy to Oracle Cloud + env: + OCI_CLI_AUTH: instance_principal + run: | + ssh -i ${{ secrets.ORACLE_CLOUD_SSH_PRIVATE_KEY }} ${{ secrets.ORACLE_CLOUD_SSH_USER }}@${{ secrets.ORACLE_CLOUD_IP }} << EOF + git pull origin master + docker compose down + docker compose pull + docker compose up -d + EOF