-
Notifications
You must be signed in to change notification settings - Fork 58
31 lines (27 loc) · 956 Bytes
/
CD.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
name: Go CD
on:
push:
branches:
- main
workflow_run:
workflows: ["Go CI"]
types:
- completed
jobs:
push-image:
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'pull_request' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
steps:
- uses: actions/checkout@v3
- name: Log into Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push Docker image
run: |
SHA=${{ github.sha }}
docker build -t devhatt/pet-dex-backend:$SHA .
docker push devhatt/pet-dex-backend:$SHA
docker tag devhatt/pet-dex-backend:$SHA devhatt/pet-dex-backend:latest
docker push devhatt/pet-dex-backend:latest