forked from omec-project/pfcpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (67 loc) · 2.27 KB
/
main.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022-present Open Networking Foundation
name: Publish pfcpsim
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
env:
DOCKER_REPO: 'opennetworking/pfcpsim'
steps:
- name: Checkout this repository
uses: actions/checkout@v2
- name: Read version file
run: echo VERSION=$(cat ./VERSION) >> $GITHUB_ENV
- name: Build protobuf
id: check
run: |
make build-proto
echo "::set-output name=PORCELAIN::`git status --porcelain`"
# Verify that protobuf is in sync with changes
- name: Check protobuf is sync
if: ${{ steps.check.outputs.PORCELAIN != '' }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Please run make build-proto and commit changes to compiled protobuf')
- name: Login to DockerHub
uses: docker/login-action@v1
# perform login only on main branch
if: ${{ github.ref == 'refs/heads/main' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get short SHA
run: echo GIT_SHA_SHORT=$(git rev-parse --short HEAD) >> $GITHUB_ENV
- name: Build with Docker
uses: docker/build-push-action@v2
with:
context: .
push: false
load: true
tags: |
${{ env.DOCKER_REPO }}:${{ env.VERSION }}
${{ env.DOCKER_REPO }}:latest
${{ env.DOCKER_REPO }}:${{ env.GIT_SHA_SHORT }}
target: 'pfcpsim'
- name: Test docker build
run: |
docker run --rm ${{ env.DOCKER_REPO }}:latest --help
docker run --rm --entrypoint pfcpctl ${{ env.DOCKER_REPO }}:latest --help
- name: Push to registry
uses: docker/build-push-action@v2
with:
context: .
# build on feature branches, push only on main branch
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
${{ env.DOCKER_REPO }}:${{ env.VERSION }}
${{ env.DOCKER_REPO }}:latest
${{ env.DOCKER_REPO }}:${{ env.GIT_SHA_SHORT }}
target: 'pfcpsim'