ci: Build fixes

- Simplify builds by separating dev/stable workflows
- Fix Helm deploy key
- Remove deploy_key.env (already using deploy key in secrets)
- Fix paths matching on push and pull_request triggers
- Fix possible issues with tag difference between ERPNext and Frappe (add tag resolving step before pushing)
- Don't login, push Docker images and release Helm chart on forks
- Don't test on version 12 (there's no test for this version)
- Remove frappe-installer (from chore: use github actions #525)
- Fix badges in readme
This commit is contained in:
Lev
2021-10-31 08:32:58 +03:00
committed by GitHub
parent 37b8ccece1
commit 2da9c02d58
8 changed files with 216 additions and 452 deletions

View File

@@ -2,4 +2,7 @@
TAGS=$(git ls-remote --refs --tags --sort='v:refname' https://github.com/$REPO "v$VERSION.*")
TAG=$(echo $TAGS | tail -n1 | sed 's/.*\///')
echo $TAG
echo "GIT_TAG=$TAG" >> $GITHUB_ENV
echo "GIT_BRANCH=version-$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV

11
.github/scripts/install-deps-and-test.sh vendored Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
sudo apt-get install -y w3m
./tests/check-format.sh
./tests/docker-test.sh
# This is done to not to rebuild images in the next step
git clean -fdx

88
.github/workflows/build_develop.yml vendored Normal file
View File

@@ -0,0 +1,88 @@
name: Build Develop
on:
pull_request:
branches:
- main
paths:
- .github/**
- build/**
- installation/**
- tests/**
- .dockerignore
- docker-bake.hcl
- docker-compose.yml
- env*
# Nightly builds at 12:00 am
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
build_bench:
name: Bench image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
if: github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: frappe-bench
push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }}
build_main:
name: Frappe and ERPNext images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
if: github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Frappe images
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: frappe-develop
load: true
- name: Build ERPNext images
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: erpnext-develop
load: true
- name: Test
run: ./.github/scripts/install-deps-and-test.sh
- name: Push Frappe images
if: github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request'
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: frappe-develop
push: true
- name: Push ERPNext images
if: github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request'
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: erpnext-develop
push: true

111
.github/workflows/build_stable.yml vendored Normal file
View File

@@ -0,0 +1,111 @@
name: Build Stable
on:
push:
branches:
- main
paths:
- .github/**
- build/**
- installation/**
- tests/**
- .dockerignore
- docker-bake.hcl
- docker-compose.yml
- env*
# Triggered from frappe/frappe and frappe/erpnext on releases
repository_dispatch:
workflow_dispatch:
jobs:
build:
name: Frappe and ERPNext images
runs-on: ubuntu-latest
strategy:
matrix:
version: [12, 13]
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
if: github.repository == 'frappe/frappe_docker'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Frappe variables
run: ./.github/scripts/get-latest-tag.sh
env:
REPO: frappe/frappe
VERSION: ${{ matrix.version }}
- name: Build Frappe images
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: frappe-stable
load: true
- name: Setup ERPNext variables
run: ./.github/scripts/get-latest-tag.sh
env:
REPO: frappe/erpnext
VERSION: ${{ matrix.version }}
- name: Build ERPNext images
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: erpnext-stable
load: true
- name: Test
if: ${{ matrix.version != 12 }}
run: ./.github/scripts/install-deps-and-test.sh
- name: Setup Frappe variables
if: github.repository == 'frappe/frappe_docker'
run: ./.github/scripts/get-latest-tag.sh
env:
REPO: frappe/frappe
VERSION: ${{ matrix.version }}
- name: Push Frappe images
if: github.repository == 'frappe/frappe_docker'
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: frappe-stable
push: true
- name: Setup ERPNext variables
if: github.repository == 'frappe/frappe_docker'
run: ./.github/scripts/get-latest-tag.sh
env:
REPO: frappe/erpnext
VERSION: ${{ matrix.version }}
- name: Push ERPNext images
if: github.repository == 'frappe/frappe_docker'
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: erpnext-stable
push: true
- name: Setup Helm deploy key
if: github.repository == 'frappe/frappe_docker'
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.HELM_DEPLOY_KEY }}
- name: Release Helm Chart
if: github.repository == 'frappe/frappe_docker'
run: |
pip install --upgrade pip
git clone git@github.com:frappe/helm.git && cd helm
pip install -r release_wizard/requirements.txt
./release_wizard/wizard 13 patch --remote origin --ci

View File

@@ -1,193 +0,0 @@
name: Build
on:
push:
branches:
- main
paths:
- .github/workflows/docker.yml
- build/**
- installation/**
- tests/**
- .dockerignore
- docker-bake.hcl
- docker-compose.yml
- env*
pull_request:
branches:
- main
paths:
- .github/workflows/docker.yml
- build/**
- installation/**
- tests/**
- .dockerignore
- docker-bake.hcl
- docker-compose.yml
- env*
# Nightly builds at 12:00 am
schedule:
- cron: 0 0 * * *
repository_dispatch: # Triggered from frappe/frappe and frappe/erpnext on releases
workflow_dispatch: # Manually triggered
inputs:
version:
description: Frappe and ERPNext version. Set to "12", "13" for latest stable versions or "develop" for nightly builds.
required: true
jobs:
resolve-matrix:
name: Resolve matrix configuration
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
build-target: ${{ steps.get-build-target.outputs.build-target }}
steps:
- uses: actions/checkout@v2
- name: Get matrix
id: get-matrix
run: |
if [ $GITHUB_EVENT_NAME == "repository_dispatch" ] || [ $GITHUB_EVENT_NAME == "push" ]; then
MATRIX='[{"version": "12"}, {"version": "13"}]'
elif [ $GITHUB_EVENT_NAME == "schedule" ] || [ $GITHUB_EVENT_NAME == "pull_request" ]; then
MATRIX='[{"version": "develop"}]'
elif [ $GITHUB_EVENT_NAME == "workflow_dispatch" ]; then
MATRIX='[{"version": "${{ github.event.inputs.version }}"}]'
fi
echo ::set-output name=matrix::{\"include\":$MATRIX}
echo $MATRIX
- name: Get build target
id: get-build-target
run: |
IS_DEVELOP=$(echo $MATRIX | jq 'any(.include[].version == "develop"; .)')
if [ $IS_DEVELOP == "true" ]; then
BUILD_TARGET_SUFFIX="develop"
else
BUILD_TARGET_SUFFIX="stable"
fi
echo $BUILD_TARGET_SUFFIX
echo ::set-output name=build-target::$BUILD_TARGET_SUFFIX
env:
MATRIX: ${{ steps.get-matrix.outputs.matrix }}
build_bench:
name: Bench image
needs: resolve-matrix
runs-on: ubuntu-latest
if: needs.resolve-matrix.outputs.build-target == 'develop'
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: frappe-bench
push: ${{ github.event_name != 'pull_request' }}
build_main:
name: Frappe and ERPNext images
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.resolve-matrix.outputs.matrix) }}
needs: resolve-matrix
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get latest Frappe tag
if: needs.resolve-matrix.outputs.build-target == 'stable'
run: |
GIT_TAG=$(./.github/scripts/get-latest-tag.sh)
echo $GIT_TAG
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
echo "GIT_BRANCH=version-$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
env:
REPO: frappe/frappe
VERSION: ${{ matrix.version }}
- name: Build Frappe images
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: ${{ format('{0}-{1}', 'frappe', needs.resolve-matrix.outputs.build-target )}}
load: true
- name: Get latest ERPNext tag
if: needs.resolve-matrix.outputs.build-target == 'stable'
run: |
GIT_TAG=$(./.github/scripts/get-latest-tag.sh)
echo $GIT_TAG
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
echo "GIT_BRANCH=version-$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
env:
REPO: frappe/erpnext
VERSION: ${{ matrix.version }}
- name: Build ERPNext images
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: ${{ format('{0}-{1}', 'erpnext', needs.resolve-matrix.outputs.build-target )}}
load: true
- name: Install test dependencies
run: sudo apt-get install -y w3m
- name: Test
if: github.event_name == 'pull_request'
run: |
./tests/check-format.sh
./tests/docker-test.sh
# This is done to not to rebuild images in the next step
git reset --hard @{u}
- name: Push Frappe images
if: github.event_name != 'pull_request'
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: ${{ format('{0}-{1}', 'frappe', needs.resolve-matrix.outputs.build-target )}}
push: true
- name: Push ERPNext images
if: github.event_name != 'pull_request'
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: ${{ format('{0}-{1}', 'erpnext', needs.resolve-matrix.outputs.build-target )}}
push: true
- name: Release Helm Chart
if: needs.resolve-matrix.outputs.build-target == 'stable'
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.HELM_DEPLOY_KEY }}
run: |
pip install --upgrade pip
git clone git@github.com:frappe/helm.git && cd helm
pip install -r release_wizard/requirements.txt
./release_wizard/wizard 13 patch --remote origin --ci