Skip to content

Commit

Permalink
Migrate to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslorentz committed Oct 20, 2024
1 parent 13f9546 commit 04b345e
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 76 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/ci-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI Pipeline

on:
push:
branches:
- '*'
tags:
- '*'

jobs:
build_binaries:
name: Build Binaries
runs-on: ubuntu-20.04

steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.8

- name: Checkout Code
uses: actions/checkout@v4

- name: Build
run: |
export PATH="$GOBIN:$PATH"
. build.sh
env:
ARTIFACTS: ${{ runner.temp }}/artifacts
shell: bash

- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: binaries
path: ${{ runner.temp }}/artifacts/binaries

linux:
name: Linux
runs-on: ubuntu-20.04
needs: build_binaries

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: binaries
path: artifacts

- name: Run Docker Tests
run: . run-docker-tests-linux.sh
shell: bash

- name: Build Docker Images
run: ./build-images-linux.sh
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
shell: bash

windows:
name: Windows
runs-on: windows-2022
needs: build_binaries

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: binaries
path: artifacts

# Uncomment this step if needed once windows docker tests are implemented
# - name: Run Docker Tests (Windows)
# run: .\run-docker-tests-windows.sh
# shell: bash

- name: Build Docker Images
run: .\build-images-windows.sh
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
shell: bash
70 changes: 0 additions & 70 deletions azure-pipelines.yml

This file was deleted.

6 changes: 3 additions & 3 deletions build-images-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OUTPUT="type=local,dest=local"
TAGS=
TAGS_ALPINE=

if [[ "${BUILD_SOURCEBRANCH}" == "refs/heads/master" ]]; then
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "Building and pushing CI images"

docker login -u lucaslorentz -p "$DOCKER_PASSWORD"
Expand All @@ -22,8 +22,8 @@ if [[ "${BUILD_SOURCEBRANCH}" == "refs/heads/master" ]]; then
TAGS_ALPINE="-t lucaslorentz/caddy-docker-proxy:ci-alpine"
fi

if [[ "${BUILD_SOURCEBRANCH}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
RELEASE_VERSION=$(echo $BUILD_SOURCEBRANCH | cut -c11-)
if [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
RELEASE_VERSION=$(echo $GITHUB_REF | cut -c11-)

echo "Releasing version ${RELEASE_VERSION}..."

Expand Down
6 changes: 3 additions & 3 deletions build-images-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ docker build -f Dockerfile-nanoserver . \
--build-arg NANOSERVER_VERSION=ltsc2022 \
-t lucaslorentz/caddy-docker-proxy:ci-nanoserver-ltsc2022

if [[ "${BUILD_SOURCEBRANCH}" == "refs/heads/master" ]]; then
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "Pushing CI images"

docker login -u lucaslorentz -p "$DOCKER_PASSWORD"
docker push lucaslorentz/caddy-docker-proxy:ci-nanoserver-1809
docker push lucaslorentz/caddy-docker-proxy:ci-nanoserver-ltsc2022
fi

if [[ "${BUILD_SOURCEBRANCH}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
RELEASE_VERSION=$(echo $BUILD_SOURCEBRANCH | cut -c11-)
if [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
RELEASE_VERSION=$(echo $GITHUB_REF | cut -c11-)

echo "Releasing version ${RELEASE_VERSION}..."

Expand Down

0 comments on commit 04b345e

Please sign in to comment.