Skip to content

Commit 2d9631f

Browse files
author
Ben Du
authored
Automatically build and push docker image on every commit to main (#2)
1 parent e93d0d7 commit 2d9631f

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: build
22

33
on:
4-
push:
5-
branches: [ main ]
64
pull_request:
75
branches: [ main ]
86

.github/workflows/deploy.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
9+
deploy:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_REPOSITORY: ghcr.io/${{ github.repository }}
13+
permissions:
14+
contents: read
15+
packages: write
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.17
23+
24+
- name: Build image
25+
run: make docker-build
26+
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@v1
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Tag image for github container repository with commit SHA
35+
run: 'docker tag controller:latest $GITHUB_REPOSITORY:${{env.GITHUB_SHA}}'
36+
37+
- name: Push image for github container repository with commit SHA
38+
run: 'docker push controller:latest $GITHUB_REPOSITORY:${{env.GITHUB_SHA}}'
39+
40+
- name: Tag image for github container repository with latest
41+
run: 'docker tag controller:latest $GITHUB_REPOSITORY:latest'
42+
43+
- name: Push image for github container repository with latest
44+
run: 'docker push controller:latest $GITHUB_REPOSITORY:latest'

0 commit comments

Comments
 (0)