Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Workflows implementation #948

Merged
merged 5 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/docker-dev-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build Gladys dev images

on:
workflow_dispatch:

jobs:
build-front:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup nodejs
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: cd front && npm install && npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v1
with:
name: static
path: front/build
docker:
needs: build-front
name: Build and Push Gladys dev images
runs-on: ubuntu-latest
env:
# Export environment variables for all stages.
DOCKER_CLI_EXPERIMENTAL: enabled # for 'docker buildx'
DOCKERHUB_USER: ${{secrets.DOCKERHUB_USER}}
DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}
DOCKERHUB_REPO: gladysassistant/gladys
DOCKER_PLATFORMS: >
linux/amd64
linux/arm/v7
linux/arm/v6
linux/arm64/v8
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v1
with:
name: static
- name: Set up image tag
run: |
set -vx
echo "TAG=dev" >> $GITHUB_ENV
echo "DOCKER_BASE=${DOCKERHUB_REPO}" >> $GITHUB_ENV
- name: Install Docker buildx
run: |
set -vx
# Install up-to-date version of docker, with buildx support.
docker_apt_repo='https://download.docker.com/linux/ubuntu'
curl -fsSL "${docker_apt_repo}/gpg" | sudo apt-key add -
os="$(lsb_release -cs)"
sudo add-apt-repository "deb [arch=amd64] $docker_apt_repo $os stable"
sudo apt-get update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# Enable docker daemon experimental support (for 'pull --platform').
config='/etc/docker/daemon.json'
if [[ -e "$config" ]]; then
sudo sed -i -e 's/{/{ "experimental": true, /' "$config"
else
echo '{ "experimental": true }' | sudo tee "$config"
fi
sudo systemctl restart docker
# Install QEMU multi-architecture support for docker buildx.
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# Instantiate docker buildx builder with multi-architecture support.
docker buildx create --name gladysbuilder
docker buildx use gladysbuilder
# Start up buildx and verify that all is OK.
docker buildx inspect --bootstrap
- name: Build multi arch images with buildx
run: |
set -vx
echo "$DOCKERHUB_PASSWORD" \
| docker login -u="$DOCKERHUB_USER" --password-stdin
function buildx() {
docker buildx build \
--platform ${DOCKER_PLATFORMS// /,} \
--push \
-f docker/Dockerfile.buildx \
"$@" \
.
}
buildx -t "$DOCKER_BASE:$TAG" --target gladys
72 changes: 72 additions & 0 deletions .github/workflows/docker-pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build Gladys amd64 images on PR

on:
pull_request:
branches: [ master ]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build-front:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup nodejs
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: cd front && npm install && npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v1
with:
name: static
path: front/build
docker:
needs: build-front
name: Build Gladys amd64 images
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v1
with:
name: static
- name: Get PR number
run: |
set -vx
echo "PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" >> $GITHUB_ENV
- name: Set up image tag
run: |
set -vx
echo "TAG=PR${PR_NUMBER}" >> $GITHUB_ENV
- name: Installing Docker
run: |
set -vx
# Install up-to-date version of docker, with buildx support.
docker_apt_repo='https://download.docker.com/linux/ubuntu'
curl -fsSL "${docker_apt_repo}/gpg" | sudo apt-key add -
os="$(lsb_release -cs)"
sudo add-apt-repository "deb [arch=amd64] $docker_apt_repo $os stable"
sudo apt-get update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# Enable docker daemon experimental support (for 'pull --platform').
config='/etc/docker/daemon.json'
if [[ -e "$config" ]]; then
sudo sed -i -e 's/{/{ "experimental": true, /' "$config"
else
echo '{ "experimental": true }' | sudo tee "$config"
fi
sudo systemctl restart docker
- name: Build amd64 images for PR
run: |
set -vx
touch qemu-amd64-static
docker build -f ./docker/Dockerfile \
--build-arg TARGET=amd64 \
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--build-arg VERSION=$PR_NUMBER \
.