Skip to content

Commit

Permalink
Merge pull request #14 from LyraPhase/automate-deploy
Browse files Browse the repository at this point in the history
actions: Add initial deploy workflow
  • Loading branch information
trinitronx committed Jul 9, 2024
2 parents 9b5fbc8 + e1c3c31 commit b5b35b1
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Deploy to DigitalOcean

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- id: setup_buildx
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
builder: ${{ steps.setup_buildx.outputs.name }}
cache-from: type=gha
cache-to: type=gha, mode=max
tags: lyraphase/phasik.tv:latest,lyraphase/phasik.tv:${{ github.sha }}
# tags: registry.digitalocean.com/<registry-name>/<repository_name>:${{ github.sha }}

- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Set app ID variable
id: app_id
run: echo "APP_ID=$(doctl apps list --no-header --format 'ID,Spec.Name' | grep 'docker-phasik-tv' | awk '{print $1}')" >> $GITHUB_ENV

- name: Deploy to DigitalOcean App
run: doctl apps update ${{ steps.app_id.outputs.APP_ID }} --spec ${{github.workspace}}/.do/app.yaml

# - name: Deploy to DigitalOcean App (no spec update)
# run: doctl apps create-deployment ${{ steps.app_id.outputs.APP_ID }} --wait
# TODO: Use DigitalOcean K8s for scaling?
# - name: Log in to DigitalOcean Container Registry
# run: doctl registry login

# - name: Update deployment file
# run: |
# TAG=${{ github.sha }}
# sed -i 's|<IMAGE>|registry.digitalocean.com/<registry-name>/<repository_name>:'${TAG}'|' k8s/deployment.yml

# - name: Save DigitalOcean kubeconfig
# run: doctl kubernetes cluster kubeconfig save <cluster-name>

# - name: Deploy to DigitalOcean Kubernetes
# run: kubectl apply -f k8s/deployment.yml

# - name: Verify deployment
# run: kubectl rollout status deployment/<deployment_name>

0 comments on commit b5b35b1

Please sign in to comment.