Skip to content

Test action

Test action #143

Workflow file for this run

name: Build packages
on:
push:
branches:
- 'release/**'
- 'hotfix/**'
- 'develop'
- 'feature/action-trigger-OCI'
paths:
- 'install/common/**'
- 'install/deb/**'
- 'install/rpm/**'
- '.github/workflows/build_packages.yml'
workflow_dispatch:
inputs:
branch-buildtools:
description: 'Branch for buildtools repository'
required: true
default: 'develop'
branch-client:
description: 'Branch for client repository'
required: true
default: 'develop'
branch-server:
description: 'Branch for server repository'
required: true
default: 'develop'
deb_build:
description: 'Trigger DEB build'
required: false
default: 'false'
rpm_build:
description: 'Trigger RPM build'
required: false
default: 'false'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
PRODUCT: "DocSpace"
PRODUCT_LOW: "docspace"
BUILD_NUMBER: ${{ github.run_number }}
PACKAGE_DIRECTORY: "/home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}"
BRANCH_BUILDTOOLS: 'feature/action-trigger-OCI'
BRANCH_CLIENT: 'feature/action-trigger-OCI'
BRANCH_SERVER: 'feature/action-trigger-OCI'
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
build_all: ${{ steps.changes.outputs.build_all }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine changed
id: changes
run: |
git fetch --no-tags --prune --depth=2
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD || true)
echo "$CHANGED_FILES"
if echo "$CHANGED_FILES" | grep -qE '^.github/workflows/build_packages.yml'; then
echo "build_all=true" >> $GITHUB_OUTPUT
else
echo "build_all=false" >> $GITHUB_OUTPUT
fi
echo ">>> OUTPUT CONTENT <<<"
cat $GITHUB_OUTPUT
- name: Verify build_all
run: |
cat $GITHUB_OUTPUT
- name: Debug build_all
run: |
echo "build_all=${{ steps.changes.outputs.build_all }}"
- name: Set matrix
id: set-matrix
run: |
package_types=()
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
[[ "${{ github.event.inputs.deb_build }}" == "true" ]] && package_types+=("deb")
[[ "${{ github.event.inputs.rpm_build }}" == "true" ]] && package_types+=("rpm")
elif [[ "${{ steps.changes.outputs.build_all }}" == "true" ]]; then
package_types+=("deb" "rpm")
else
[[ "${{ github.event.inputs.deb_build }}" == "true" ]] && package_types+=("deb")
[[ "${{ github.event.inputs.rpm_build }}" == "true" ]] && package_types+=("rpm")
fi
[[ ${#package_types[@]} -eq 0 ]] && exit 0
matrix=$(printf '%s\n' "${package_types[@]}" | jq -R . | jq -sc '{include: map({packageType: .})}')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build:
name: Build Packages
needs: prepare
runs-on: ubuntu-22.04
strategy:
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set product version
run: |
PRODUCT_VERSION=$(grep -oP '\d+\.\d+\.\d+' <<< "${BRANCH_BUILDTOOLS//\//} ${BRANCH_CLIENT//\//} \
${BRANCH_SERVER//\//}" | head -n1)
echo "PRODUCT_VERSION=${PRODUCT_VERSION:-3.0.1}" >> $GITHUB_ENV
trigger_oci:
name: Trigger ci-oci-install Workflow
needs: build
runs-on: ubuntu-22.04
if: ${{ success() }}
steps:
- name: Trigger CI-OCI-Install Workflow
run: |
echo "build_all: '${{ needs.prepare.outputs.build_all }}'"
deb_build="${{ github.event.inputs.deb_build }}"
rpm_build="${{ github.event.inputs.rpm_build }}"
[[ "${{ needs.prepare.outputs.build_all }}" == "true" ]] && deb_build="true" && rpm_build="true"
echo "deb_build: $deb_build"
echo "rpm_build: $rpm_build"
# curl \
# -X POST \
# -u "${{ secrets.USERNAME}}:${{secrets.TOKEN}}" \
# https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/actions/workflows/85067971/dispatches \
# -H "Accept: application/vnd.github.everest-preview+json" \
# --data '{
# "ref": "'"${{ github.ref_name }}"'",
# "inputs": {
# "deb_build": "'"${deb_build}"'",
# "rpm_build": "'"${rpm_build}"'"
# }
# }'