-
Notifications
You must be signed in to change notification settings - Fork 21
52 lines (46 loc) · 1.59 KB
/
docker-publish-api.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
name: Docker Build
on:
push:
paths:
- '**.rs'
- '**.toml'
- 'API/Dockerfile'
- '.github/workflows/docker-publish-api.yml'
branches: [ main, ci-test ]
env:
IMAGE_NAME: api
jobs:
build-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --build-arg VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') --file Dockerfile --tag $IMAGE_NAME
working-directory: ./API
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
working-directory: ./API
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push --all-tags $IMAGE_ID
working-directory: ./API
deploy:
needs:
- build-api
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: fjogeleit/http-request-action@v1
with:
url: 'https://watchtower.montague.im/v1/update'
method: 'POST'
timeout: 60000
customHeaders: '{"Authorization": "Bearer ${{ secrets.TOKEN }}"}'