-
Notifications
You must be signed in to change notification settings - Fork 3
42 lines (34 loc) · 1018 Bytes
/
cicd.yaml
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
32
33
34
35
36
37
38
39
40
41
42
name: Build and Push Docker Image
on:
push:
branches:
- '**' # Triggers on push to any branch
branches-ignore:
- master # Exclude master branch
pull_request:
branches:
- master # Triggers on PR to master branch
workflow_dispatch: # Manually trigger the workflow
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
run: docker build -t server .
deploy:
needs: build # Ensure deploy job waits for build job
runs-on: ubuntu-latest
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v2
if: github.ref == 'refs/heads/master'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image
if: github.ref == 'refs/heads/master'
run: docker push server:latest