pollo/.github/workflows/deploy.yml
2024-10-16 19:21:44 -06:00

35 lines
1.3 KiB
YAML

name: Build and Push Docker Image to DO Container Registry
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{ github.event.repository.name }}:${{ github.sha }}
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Tag images
run: |
docker tag ${{ github.event.repository.name }}:${{ github.sha }} ${{ secrets.DIGITALOCEAN_REGISTRY }}/${{ github.event.repository.name }}:${{ github.sha }}
docker tag ${{ github.event.repository.name }}:${{ github.sha }} ${{ secrets.DIGITALOCEAN_REGISTRY }}/${{ github.event.repository.name }}:latest
- name: Push images to DO Container Registry
run: |
docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}/${{ github.event.repository.name }}:${{ github.sha }}
docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}/${{ github.event.repository.name }}:latest