Skip to content

Commit ea5d611

Browse files
committed
initial stab at moving to github actions
1 parent f7dcb9b commit ea5d611

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

.github/bin/docker-release.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
4+
5+
export DOCKER_ORG="travisghansen"
6+
export DOCKER_PROJECT="kubernetes-pfsense-controller"
7+
export DOCKER_REPO="${DOCKER_ORG}/${DOCKER_PROJECT}"
8+
9+
if [[ $GITHUB_REF == refs/tags/* ]]; then
10+
export GIT_TAG=${GITHUB_REF#refs/tags/}
11+
else
12+
export GIT_BRANCH=${GITHUB_REF#refs/heads/}
13+
fi
14+
15+
if [[ -n "${GIT_TAG}" ]]; then
16+
docker buildx build --progress plain --pull --push --platform "${DOCKER_BUILD_PLATFORM}" -t ${DOCKER_REPO}:${GIT_TAG} .
17+
elif [[ -n "${GIT_BRANCH}" ]]; then
18+
if [[ "${GIT_BRANCH}" == "master" ]]; then
19+
docker buildx build --progress plain --pull --push --platform "${DOCKER_BUILD_PLATFORM}" -t ${DOCKER_REPO}:latest .
20+
else
21+
docker buildx build --progress plain --pull --push --platform "${DOCKER_BUILD_PLATFORM}" -t ${DOCKER_REPO}:${GIT_BRANCH} .
22+
fi
23+
else
24+
:
25+
fi

.github/workflows/main.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context
2+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif
3+
name: CI
4+
5+
on:
6+
push:
7+
tags:
8+
- "v*"
9+
branches:
10+
- master
11+
- next
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: cancel previous runs
19+
uses: styfle/[email protected]
20+
with:
21+
access_token: ${{ github.token }}
22+
23+
- uses: actions/checkout@v2
24+
25+
- name: application build
26+
uses: php-actions/composer@v4
27+
with:
28+
command: buildphar
29+
30+
- name: create release
31+
id: create_release
32+
if: ${{ github.ref == v* }}
33+
uses: actions/create-release@v1
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
with:
37+
tag_name: ${{ github.ref }}
38+
release_name: ${{ github.ref }}
39+
draft: false
40+
prerelease: false
41+
42+
- name: upload release asset
43+
id: upload-release-asset
44+
if: ${{ github.ref == v* }}
45+
uses: actions/upload-release-asset@v1
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
# This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
50+
upload_url: ${{ steps.create_release.outputs.upload_url }}
51+
asset_path: ./releases/kubernetes-pfsense-controller-${{ github.ref }}.phar
52+
asset_name: kubernetes-pfsense-controller-${{ github.ref }}.phar
53+
asset_content_type: application/zip
54+
55+
- name: docker build
56+
run: |
57+
export ARCH=$([ $(uname -m) = "x86_64" ] && echo "amd64" || echo "arm64")
58+
mkdir -p ~/.docker/cli-plugins/
59+
wget -qO ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-${ARCH}
60+
chmod a+x ~/.docker/cli-plugins/docker-buildx
61+
docker info
62+
docker buildx version
63+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
64+
docker buildx create --name xbuilder --use
65+
docker buildx inspect --bootstrap
66+
.github/bin/docker-release.sh
67+
68+
env:
69+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
70+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
71+
DOCKER_CLI_EXPERIMENTAL: enabled
72+
DOCKER_BUILD_PLATFORM: linux/amd64,linux/arm/v7,linux/arm64

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
FROM php:7.3-cli-alpine
1+
FROM php:7.4-cli-alpine
2+
3+
ARG TARGETPLATFORM
4+
ARG BUILDPLATFORM
5+
6+
RUN echo "I am running build on $BUILDPLATFORM, building for $TARGETPLATFORM"
27

38
RUN \
49
apk add --no-cache bzip2-dev \

0 commit comments

Comments
 (0)