DocSpace-buildtools/.github/workflows/main-build.yml
Danil Titarenko 9fa4a2bf3e
Run zap scanner only on cron or workflow_dispatch event (#74)
* Run zap scanner only on `schedule` or `workflow_dispatch` trigger

* Send event name from cron action

* Revert some changes

* Add condition that check `repository_dispatch` event name
2023-11-27 20:04:16 +03:00

85 lines
2.5 KiB
YAML

name: 4testing multiarch-build
on:
workflow_dispatch:
inputs:
zap:
description: 'Run ZAP scanning after build?'
type: boolean
repository_dispatch:
types:
- cron-trigger-action
- config-trigger-action
- client-trigger-action
- server-trigger-action
env:
DOCKER_PATH: "/install/docker"
REPO: "onlyoffice"
DOCKER_IMAGE_PREFIX: "4testing-docspace"
DOCKERFILE: "Dockerfile.app"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64]
branch: ${{ github.event.client_payload.branches }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ matrix.branch }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Free Disk Space
run: |
sudo rm -rf /usr/local/lib/android /opt/ghc
sudo docker image prune --all --force
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build 4testing
id: build
run: |
cd .${DOCKER_PATH}
if [ "${{ matrix.branch }}" = "develop" ]; then
DOCKER_TAG="develop.${{ github.run_number }}"
else
DOCKER_TAG=$(echo "${{ matrix.branch }}" | sed '/^release\b\|^hotfix\b\|^feature\b/s/release.*\/\|hotfix.*\/\|feature.*\///; s/-git-action$//; s/^v//').${{github.run_number}}
fi
export DOCKER_TAG
docker buildx bake -f build.yml \
--set *.args.GIT_BRANCH=${{ matrix.branch }} \
--set *.platform=linux/amd64 \
--push
echo "version=${DOCKER_TAG}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Run zap action if needed
if: ${{ github.event.action == 'cron-trigger-action' || github.event_name == 'workflow_dispatch' }}
env:
RUN_ZAP: ${{ github.event.inputs.zap || 'true' }}
GITHUB_TOKEN: ${{ secrets.TOKEN }}
VERSION: ${{ steps.build.outputs.version }}
shell: bash
run: |
if [[ ${{ matrix.branch }} =~ release || ${{ matrix.branch }} =~ hotfix && ${RUN_ZAP} == true ]]; then
gh workflow run zap-scan.yaml \
--repo ONLYOFFICE/DocSpace \
-f branch=${{ matrix.branch }} \
-f version=${VERSION}
fi