-
Notifications
You must be signed in to change notification settings - Fork 123
62 lines (50 loc) · 1.86 KB
/
docker-image.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
name: Build-CI
on:
push:
branches: [ "main" ]
workflow_dispatch:
inputs:
tagName:
description: 'Tag Name'
required: true
default: 'latest'
jobs:
build:
name: build-ci
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the latest loxilb Docker image
if: github.event.inputs.tagName == ''
run: docker build . --tag ghcr.io/loxilb-io/loxilb:latest
- name: Build the loxilb Docker image with given tag
if: github.event.inputs.tagName != ''
run: docker build . --tag ghcr.io/loxilb-io/loxilb:${{ github.event.inputs.tagName }}
- name: Run the loxilb docker image to check
run: docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --name loxilb ghcr.io/loxilb-io/loxilb:latest
- name: Publish the latest loxilb Docker image
if: |
github.repository == 'loxilb-io/loxilb'
&& github.event.inputs.tagName == ''
run: docker push ghcr.io/loxilb-io/loxilb:latest
- name: Publish the loxilb Docker image with given tag
if: |
github.repository == 'loxilb-io/loxilb'
&& github.event.inputs.tagName != ''
run: docker push ghcr.io/loxilb-io/loxilb:${{ github.event.inputs.tagName }}
# This is currently not supported yet for docker packages
- name: Cleanup old Docker packages
uses: actions/delete-package-versions@v3
with:
package-name: 'loxilb'
num-old-versions-to-delete: 3