-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (75 loc) · 2.9 KB
/
nomad.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
83
84
85
86
name: Nomad
on:
push:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
version:
description: 'The version of Nomad to build an image for e.g. v1.6.3'
required: true
type: string
permissions:
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get Nomad version
id: collect
run: |-
# Get latest Nomad version
NOMAD_VERSION=${{inputs.version}}
if [ -z "$NOMAD_VERSION" ]; then
NOMAD_VERSION=$(curl --silent "https://api.github.com/repos/hashicorp/nomad/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
CURRENT_VERSION=$(curl --silent --fail -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/jumppad-labs/packages/container/nomad/versions" | \
jq -r '.[].metadata.container.tags[] | select( . != null )' | \
sort -V -r | \
head -n 1)
fi
echo "version=$NOMAD_VERSION" >> "$GITHUB_OUTPUT"
echo "current=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo $NOMAD_VERSION
echo $CURRENT_VERSION
- name: Remove v in Tag
id: version
uses: ashley-taylor/[email protected]
with:
value: ${{steps.collect.outputs.version}}
regex: "v"
replacement: ""
- name: Login to GitHub Container Registry
if: steps.collect.outputs.version != steps.collect.outputs.current
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
if: steps.collect.outputs.version != steps.collect.outputs.current
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
if: steps.collect.outputs.version != steps.collect.outputs.current
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
if: steps.collect.outputs.version != steps.collect.outputs.current
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: nomad
platforms: linux/amd64,linux/arm64
build-args: |
NOMAD_VERSION=${{steps.version.outputs.value}}
push: true
tags: ghcr.io/jumppad-labs/nomad:${{steps.collect.outputs.version}}
- name: Test built image
if: steps.collect.outputs.version != steps.collect.outputs.current
run: |-
# Install Jumppad
curl https://jumppad.dev/install | bash
# Test the image
jumppad test --tags @Single --var version=${{steps.collect.outputs.version}} ./nomad/tests