Skip to content

Commit dd944a4

Browse files
authored
GitHub actions testing (#107)
* test 1 * test 2 * remove accidental pasting in commit * removed multi-platform for dev * Revert "Add button to delete machine route" This reverts commit 63041fd. * modernized release workflow * update version * Migration to Svelte 4 * cleaned up version injection * moved build arg below FROM * increment release
1 parent fab1359 commit dd944a4

File tree

26 files changed

+147
-226
lines changed

26 files changed

+147
-226
lines changed

.github/workflows/publish-dev-image.yaml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,16 @@ jobs:
1616
id: gathervars
1717
run: |
1818
# get a current BUILD_DATE
19-
echo "::set-output name=BUILD_DATE::$(date +%Y%m%d-%H%M%S)"
19+
echo "BUILD_DATE=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_ENV
2020
# set version based on BUILD_DATE
21-
echo "::set-output name=VERSION::$(date +%Y.%m.%d)-development"
22-
23-
# setting tags
24-
echo "::set-output name=TAG::development"
21+
echo "VERSION=$(date +%Y.%m.%d)-development" >> $GITHUB_ENV
2522
2623
- name: Checkout Repository
27-
uses: actions/checkout@v2
28-
29-
- name: Set up QEMU
30-
uses: docker/setup-qemu-action@v2
24+
uses: actions/checkout@v3
3125

3226
- name: Set up Docker Buildx
3327
uses: docker/setup-buildx-action@v2
3428

35-
- name: Cache Docker layers
36-
uses: actions/cache@v3
37-
with:
38-
path: /tmp/.buildx-cache
39-
key: ${{ runner.os }}-buildx-${{ github.sha }}
40-
restore-keys: ${{ runner.os }}-buildx-
41-
4229
- name: Log in to the Container registry
4330
uses: docker/login-action@v1
4431
with:
@@ -47,16 +34,13 @@ jobs:
4734
password: ${{ secrets.GITHUB_TOKEN }}
4835

4936
- name: Build and push Docker Image
50-
uses: docker/build-push-action@v2
37+
uses: docker/build-push-action@v4
5138
with:
5239
build-args: |
53-
BUILD_DATE=${{ steps.gathervars.outputs.BUILD_DATE }}
54-
VERSION=${{ steps.gathervars.outputs.VERSION }}
40+
BUILD_DATE=${{ env.BUILD_DATE }}
41+
VERSION=${{ env.VERSION }}
5542
context: ./docker/development
5643
tags: |
5744
ghcr.io/${{ github.repository }}-dev:latest
58-
ghcr.io/${{ github.repository }}-dev:${{ steps.gathervars.outputs.VERSION }}
59-
platforms: linux/amd64,linux/arm64,linux/arm32v7
60-
cache-from: type=local,src=/tmp/.buildx-cache
61-
cache-to: type=local,dest=/tmp/.buildx-cache
45+
ghcr.io/${{ github.repository }}-dev:${{ env.VERSION }}
6246
push: true

.github/workflows/publish-release.yaml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,27 @@ jobs:
1010

1111
steps:
1212
- name: Checkout Repository
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414

1515
- name: Variable Gathering
1616
id: gathervars
1717
run: |
1818
NOT_PREVIOUSLY_PUBLISHED=0
1919
# get a current BUILD_DATE
2020
VERSION=$(jq -r '.version' ./package.json)
21-
echo "::set-output name=BUILD_DATE::$(date +%Y%m%d-%H%M%S)"
22-
echo "::set-output name=VERSION::$VERSION"
21+
echo "BUILD_DATE=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_ENV
22+
echo "VERSION=$VERSION" >> $GITHUB_ENV
2323
2424
# setting tags
2525
if echo "$VERSION" | grep -q "beta"; then
26-
TAGS="ghcr.io/${{ github.repository }}:beta, ghcr.io/${{ github.repository }}:$VERSION, ghcr.io/${{ github.repository }}:latest"
27-
PRIMARY_TAG=latest
26+
echo "TAGS=ghcr.io/${{ github.repository }}:beta, ghcr.io/${{ github.repository }}:$VERSION, ghcr.io/${{ github.repository }}:latest" >> $GITHUB_ENV
2827
else
29-
TAGS="ghcr.io/${{ github.repository }}:release, ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:$VERSION"
30-
PRIMARY_TAG=latest
28+
echo "TAGS=ghcr.io/${{ github.repository }}:release, ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:$VERSION" >> $GITHUB_ENV
3129
fi
32-
echo "::set-output name=TAG::$TAGS"
33-
echo "::set-output name=PRIMARY_TAG::$PRIMARY_TAG"
30+
echo "PRIMARY_TAG=latest" >> $GITHUB_ENV
3431
# check if version has already been published
3532
$(docker manifest inspect ghcr.io/${{ github.repository }}:$VERSION > /dev/null) || NOT_PREVIOUSLY_PUBLISHED=1
36-
echo "::set-output name=NOT_PREVIOUSLY_PUBLISHED::$NOT_PREVIOUSLY_PUBLISHED"
33+
echo "NOT_PREVIOUSLY_PUBLISHED=$NOT_PREVIOUSLY_PUBLISHED" >> $GITHUB_ENV
3734
3835
- name: Set up QEMU
3936
uses: docker/setup-qemu-action@v2
@@ -42,55 +39,55 @@ jobs:
4239
uses: docker/setup-buildx-action@v2
4340

4441
- name: Log in to the Container registry
45-
uses: docker/login-action@v1
46-
if: ${{ steps.gathervars.outputs.NOT_PREVIOUSLY_PUBLISHED != 0 }}
42+
uses: docker/login-action@v2
43+
if: ${{ env.NOT_PREVIOUSLY_PUBLISHED != 0 }}
4744
with:
4845
registry: ghcr.io
4946
username: ${{ github.actor }}
5047
password: ${{ secrets.GITHUB_TOKEN }}
5148

5249
- name: Build and push Docker Image
53-
uses: docker/build-push-action@v2
54-
if: ${{ steps.gathervars.outputs.NOT_PREVIOUSLY_PUBLISHED != 0 }}
50+
uses: docker/build-push-action@v4
51+
if: ${{ env.NOT_PREVIOUSLY_PUBLISHED != 0 }}
5552
with:
5653
build-args: |
57-
BUILD_DATE=${{ steps.gathervars.outputs.BUILD_DATE }}
58-
VERSION=${{ steps.gathervars.outputs.VERSION }}
54+
BUILD_DATE=${{ env.BUILD_DATE }}
55+
VERSION=${{ env.VERSION }}
5956
context: ./docker/production
6057
tags: |
61-
${{ steps.gathervars.outputs.TAG }}
58+
${{ env.TAGS }}
6259
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
6360
push: true
6461

6562
- name: Extract build out of docker image
66-
uses: shrink/actions-docker-extract@v1
67-
if: ${{ steps.gathervars.outputs.NOT_PREVIOUSLY_PUBLISHED != 0 }}
63+
uses: shrink/actions-docker-extract@v2
64+
if: ${{ env.NOT_PREVIOUSLY_PUBLISHED != 0 }}
6865
id: extract
6966
with:
70-
image: ghcr.io/${{ github.repository }}:${{ steps.gathervars.outputs.PRIMARY_TAG }}
67+
image: ghcr.io/${{ github.repository }}:${{ env.PRIMARY_TAG }}
7168
path: web
7269

7370
- name: create release asset
74-
if: ${{ steps.gathervars.outputs.NOT_PREVIOUSLY_PUBLISHED != 0 }}
71+
if: ${{ env.NOT_PREVIOUSLY_PUBLISHED != 0 }}
7572
run: |
7673
cd "${{ steps.extract.outputs.destination }}"
7774
7z a headscale-ui.zip web
7875
7976
- name: Create Draft Release
8077
id: create_release
8178
uses: actions/create-release@v1
82-
if: ${{ steps.gathervars.outputs.NOT_PREVIOUSLY_PUBLISHED != 0 }}
79+
if: ${{ env.NOT_PREVIOUSLY_PUBLISHED != 0 }}
8380
env:
8481
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8582
with:
86-
tag_name: ${{ steps.gathervars.outputs.VERSION }}
83+
tag_name: ${{ env.VERSION }}
8784
release_name: headscale-ui
8885
draft: true
8986
prerelease: false
9087

9188
- name: upload asset to releases
9289
uses: actions/upload-release-asset@v1.0.1
93-
if: ${{ steps.gathervars.outputs.NOT_PREVIOUSLY_PUBLISHED != 0 }}
90+
if: ${{ env.NOT_PREVIOUSLY_PUBLISHED != 0 }}
9491
env:
9592
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9693
with:
@@ -101,7 +98,7 @@ jobs:
10198

10299
- name: publish release
103100
uses: eregon/publish-release@v1
104-
if: ${{ steps.gathervars.outputs.NOT_PREVIOUSLY_PUBLISHED != 0 }}
101+
if: ${{ env.NOT_PREVIOUSLY_PUBLISHED != 0 }}
105102
env:
106103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107104
with:

docker/development/dockerfile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,4 @@ USER dev-user
4949

5050
WORKDIR /data
5151

52-
ENTRYPOINT /bin/sh /staging/scripts/2-initialise.sh#!/bin/sh
53-
54-
#----#
55-
# placeholder for testing
56-
# while true; do sleep 1; done
57-
#----#
58-
59-
# set file permissions if required
60-
if [ $(id -u) -ne $(stat -c %u /data) ]
61-
then
62-
…fi
52+
ENTRYPOINT /bin/sh /staging/scripts/2-initialise.sh

docker/production/dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
FROM node:lts AS build
2+
13
# arguments
24
ARG VERSION="master"
35
# Branch to check out
46
ARG CHECKOUT_BRANCH="master"
57

6-
FROM node:lts AS build
7-
88
#environment variables
99
ENV PROJECT_NAME="headscale-ui"
1010
# URL for the github/git location

docker/production/scripts/1-image-build.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
set -x
33

44
# add dependencies
5-
# jq for parsing version information
65
# git for cloning the repository
7-
apk add --no-cache jq git
6+
apk add --no-cache git
87

98
#clone the project
109
git clone ${PROJECT_URL} ${PROJECT_NAME}
@@ -15,7 +14,6 @@ git checkout ${CHECKOUT_BRANCH}
1514
npm install
1615

1716
# inject the version number
18-
VERSION=$(jq -r '.version' package.json)
1917
sed -i "s/insert-version/${VERSION}/g" ./src/routes/settings.html/+page.svelte
2018

2119
# build the project

0 commit comments

Comments
 (0)