-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (35 loc) · 1.31 KB
/
ci.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
43
name: Build and Push Docker Image
on:
push:
branches:
- production
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Docker Buildx (for cross-platform builds, if needed)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Step 3: Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Step 4: Build the Docker image
- name: Build Docker image
run: |
docker build -t ghcr.io/${{ github.repository }}:${{ github.sha }} .
# Step 5: Push the Docker image to GitHub Container Registry
- name: Push Docker image to GitHub Container Registry
run: |
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
# Optional Step 6: Add latest tag and push it as well
- name: Tag image as latest and push
run: |
docker tag ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:latest
docker push ghcr.io/${{ github.repository }}:latest