Skip to content

feat(watchlist): create delete movie from watchlist #24

feat(watchlist): create delete movie from watchlist

feat(watchlist): create delete movie from watchlist #24

Workflow file for this run

name: Deploy to Google Cloud VM with Docker
on:
push:
branches:
- feat/docker
paths-ignore:
- README.md
- .gitignore
pull_request_target:
branches:
- master
types:
- closed
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Docker Hub Authentication
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker Image
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest .
- name: Tag Docker Image
run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest
- name: Push Docker Image to Docker Hub
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest
deploy:
runs-on: ubuntu-latest
needs: publish
steps:
- name: Set up Cloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.GCE_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_CREDENTIALS }}
export_default_credentials: true
- name: Access gcloud CLI
run: |
gcloud auth configure-docker
- name: Checkout repository
uses: actions/checkout@v3
- name: Copy docker-compose.yml into GCP Instance
uses: appleboy/scp-action@master
with:
host: ${{ secrets.GCP_VM_IP }}
username: ${{ secrets.GCP_USER }}
key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
source: 'docker-compose.yml'
target: '/home/${{ secrets.GCP_USER }}/'
- name: SSH into GCP and Run Docker Container
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.GCP_VM_IP }}
username: ${{ secrets.GCP_USER }}
key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
script: |
echo "DATABASE_URL=postgresql://${{ vars.DATABASE_USERNAME }}:${{ vars.DATABASE_PASSWORD }}@${{ vars.DATABASE_HOST }}:5432/${{ vars.DATABASE_NAME }}?schema=public" >> .env
sed -i -e 's/iqbalpa\/backend-movies/${{ secrets.DOCKERHUB_USERNAME }}\/${{ vars.DOCKER_IMAGE_NAME }}/g' docker-compose.yml
docker compose -f /home/${{ secrets.GCP_USER }}/docker-compose.yml down
docker compose -f /home/${{ secrets.GCP_USER }}/docker-compose.yml up --pull always -d
docker image prune -f -a