-
Notifications
You must be signed in to change notification settings - Fork 5
82 lines (69 loc) · 2.33 KB
/
build.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
78
79
80
81
82
name: Build
on:
push:
branches: [ main ]
paths-ignore:
- 'package.json'
- 'CHANGELOG.md'
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
tags:
required: false
description: 'Misc tags'
jobs:
build:
name: 'Build'
runs-on: ubuntu-latest
env:
BUILD_NUMBER: ${{ github.run_number }}
TARGET_PLATFORMS: linux/amd64,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_PAT }}
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Extract PR number
shell: bash
run: |
echo "##[set-output name=pr_number;]$(echo $(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH"))"
id: extract_pr_number
- name: Extract version number
shell: bash
run: |
echo "##[set-output name=version_number;]$(echo $(jq -r .version package.json))"
id: extract_version_number
- name: Build/Push (main)
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: ${{ env.TARGET_PLATFORMS }}
tags: |
ghcr.io/openziti/ziti-browzer-bootstrapper:${{ github.run_number }}
ghcr.io/openziti/ziti-browzer-bootstrapper:latest
ghcr.io/openziti/ziti-browzer-bootstrapper:${{ steps.extract_version_number.outputs.version_number }}
if: |
steps.extract_branch.outputs.branch == 'main'
- name: Build/Push (PR)
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: ${{ env.TARGET_PLATFORMS }}
tags: |
ghcr.io/openziti/ziti-browzer-bootstrapper:${{ github.run_number }}
ghcr.io/openziti/ziti-browzer-bootstrapper:PR${{ steps.extract_pr_number.outputs.pr_number }}.${{ github.run_number }}
if: |
steps.extract_branch.outputs.branch != 'main'