Merge pull request #410 from TrekkieCoder/main #469
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |