-
Notifications
You must be signed in to change notification settings - Fork 89
56 lines (54 loc) · 1.84 KB
/
publish.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Publish
on:
push:
tags:
- "v*"
jobs:
build_api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
- name: build web
run: |
npm install
npm run build
working-directory: web
- name: copy to api/static
run: |
cp -R web/dist/* api/static/
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Build Chat Binary
run: go build -v ./...
working-directory: api
- name: Test Chat
run: go test -v ./...
working-directory: api
# use root folder docker
- name: Build Chat image
run: |
docker build . --file Dockerfile -t ghcr.io/swuecho/chat:${GITHUB_REF#refs/tags/}
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push API image to GitHub Container Registry
run: |
docker push ghcr.io/swuecho/chat:${GITHUB_REF#refs/tags/}
docker tag ghcr.io/swuecho/chat:${GITHUB_REF#refs/tags/} ghcr.io/swuecho/chat:latest
docker push ghcr.io/swuecho/chat:latest
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: push to docker
run: |
docker tag ghcr.io/swuecho/chat:${GITHUB_REF#refs/tags/} echowuhao/chat:${GITHUB_REF#refs/tags/}
docker tag ghcr.io/swuecho/chat:${GITHUB_REF#refs/tags/} echowuhao/chat:latest
docker push echowuhao/chat:${GITHUB_REF#refs/tags/}
docker push echowuhao/chat:latest