35 lines
1.1 KiB
YAML
35 lines
1.1 KiB
YAML
|
name: Build and Push Docker Image
|
||
|
|
||
|
on:
|
||
|
push:
|
||
|
branches: [main]
|
||
|
pull_request:
|
||
|
branches: [main]
|
||
|
|
||
|
jobs:
|
||
|
build-and-push:
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
|
- uses: actions/checkout@v3
|
||
|
|
||
|
- name: Build the Docker image
|
||
|
run: docker build . --file Dockerfile --tag atridad:${{ 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 atridad:${{ github.sha }} registry.digitalocean.com/${{ secrets.DIGITALOCEAN_REGISTRY }}/atridotdad:${{ github.sha }}
|
||
|
docker tag atridad:${{ github.sha }} registry.digitalocean.com/${{ secrets.DIGITALOCEAN_REGISTRY }}/atridotdad:latest
|
||
|
|
||
|
- name: Push images to DO Container Registry
|
||
|
run: |
|
||
|
docker push registry.digitalocean.com/${{ secrets.DIGITALOCEAN_REGISTRY }}/atridotdad:${{ github.sha }}
|
||
|
docker push registry.digitalocean.com/${{ secrets.DIGITALOCEAN_REGISTRY }}/atridotdad:latest
|