Skip to content

Commit 0520dba

Browse files
committed
Added github actions to build and push container.
1 parent 13e55b0 commit 0520dba

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/container.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Build Docker image
21+
run: |
22+
docker build -t ghcr.io/${{ github.repository }}:${{ github.sha }} .
23+
24+
push:
25+
runs-on: ubuntu-latest
26+
needs: build
27+
if: github.ref == 'refs/heads/main'
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v3
32+
33+
- name: Log in to GitHub Container Registry
34+
uses: docker/login-action@v2
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Push Docker image
41+
run: |
42+
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}

0 commit comments

Comments
 (0)