From 173755e39e80431b6498a6773c916b48b780595a Mon Sep 17 00:00:00 2001 From: Lev Date: Sat, 30 Oct 2021 13:57:11 +0300 Subject: [PATCH 1/2] update --- .github/scripts/get-latest-tag.sh | 5 +- .github/scripts/install-deps-and-test.sh | 11 ++ .github/workflows/build_dev.yml | 88 +++++++++++ .github/workflows/build_stable.yml | 106 +++++++++++++ .github/workflows/docker.yml | 193 ----------------------- 5 files changed, 209 insertions(+), 194 deletions(-) create mode 100644 .github/scripts/install-deps-and-test.sh create mode 100644 .github/workflows/build_dev.yml create mode 100644 .github/workflows/build_stable.yml delete mode 100644 .github/workflows/docker.yml diff --git a/.github/scripts/get-latest-tag.sh b/.github/scripts/get-latest-tag.sh index 1ce4bc38..1af75311 100755 --- a/.github/scripts/get-latest-tag.sh +++ b/.github/scripts/get-latest-tag.sh @@ -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 \ No newline at end of file diff --git a/.github/scripts/install-deps-and-test.sh b/.github/scripts/install-deps-and-test.sh new file mode 100644 index 00000000..26b8449e --- /dev/null +++ b/.github/scripts/install-deps-and-test.sh @@ -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 reset --hard @{u} \ No newline at end of file diff --git a/.github/workflows/build_dev.yml b/.github/workflows/build_dev.yml new file mode 100644 index 00000000..f50a3b27 --- /dev/null +++ b/.github/workflows/build_dev.yml @@ -0,0 +1,88 @@ +name: Build Develop + +on: + 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 * * * + + 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 diff --git a/.github/workflows/build_stable.yml b/.github/workflows/build_stable.yml new file mode 100644 index 00000000..f15b442c --- /dev/null +++ b/.github/workflows/build_stable.yml @@ -0,0 +1,106 @@ +name: Build + +on: + push: + branches: + - main + paths: + - .github/workflows/docker.yml + - 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: + 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 + 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: Release Helm Chart + if: github.repository == 'frappe/frappe_docker' + 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 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 3fa70b14..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -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 - 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 - 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 - 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' - run: | - export GIT_SSH_COMMAND="ssh -i ${PWD}/deploy_key" - echo -n $HELM_DEPLOY_KEY | base64 -di > deploy_key - chmod 400 deploy_key; - ssh-keyscan github.com >> $HOME/.ssh/known_hosts 2>/dev/null; - 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 - env: - HELM_DEPLOY_KEY: ${{ secrets.HELM_DEPLOY_KEY }} From 76801aba2684e57ac48831d3543eb93b2ba0bcb7 Mon Sep 17 00:00:00 2001 From: Lev Date: Sat, 30 Oct 2021 14:01:01 +0300 Subject: [PATCH 2/2] update --- .github/workflows/build_stable.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_stable.yml b/.github/workflows/build_stable.yml index f15b442c..6e8172a9 100644 --- a/.github/workflows/build_stable.yml +++ b/.github/workflows/build_stable.yml @@ -94,11 +94,14 @@ jobs: targets: erpnext-stable push: true - - name: Release Helm Chart + - 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