This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (58 loc) · 2.12 KB
/
release_ci.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
57
58
59
60
61
62
63
name: Release CI
on:
push:
branches: [master]
env:
DOCKER_IMAGE: ghcr.io/linkkky/waitlist.api.inssa.club
VERSION: ${{github.sha}}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out the source code
uses: actions/checkout@v2
- name: Setup docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{runner.os}}-buildx-${{env.VERSION}}
resotre-keys: |
${{runner.os}}-buildx-
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.LINKKY_PAT}}
- name: Build & Push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{steps.buildx.outputs.name}}
push: ${{github.event_name != 'pull_request'}}
tags: ${{env.DOCKER_IMAGE}}:${{env.VERSION}}
deploy:
needs: build
name: Deploy
runs-on: [self-hosted, production]
steps:
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.LINKKY_PAT}}
- name: Rolling update the service
run: |
docker service update --force --update-parallelism 1 --image ${{ env.DOCKER_IMAGE }}:${{ env.VERSION }} inssa_waitlist
cleanup:
needs: [build, deploy]
name: Clean up docker images
runs-on: [self-hosted, production]
steps:
- name: Remove images of older versions
run: docker rmi $(docker images --filter "before=${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}" --filter=reference="${{ env.DOCKER_IMAGE }}:*" -q)