Skip to content
Merged
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
67 changes: 65 additions & 2 deletions .github/workflows/hidrive-next-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ jobs:

- name: Get NC version
id: get_nc_version
continue-on-error: false
run: |
NC_VERSION=$(jq -r '.ncVersion' version.json)
echo "NC_VERSION: $NC_VERSION"
Expand Down Expand Up @@ -150,9 +151,12 @@ jobs:
# Upload the artifact to the Artifactory repository on PR *OR* on "ionos-dev|ionos-stable" branch push defined in the on:push:branches
if: github.event_name == 'pull_request' || github.ref_name == 'ionos-dev' || github.ref_name == 'ionos-stable'

name: Push artifact to artifactory as dev build
name: Push to artifactory
needs: hidrive-next-build

outputs:
ARTIFACTORY_LAST_BUILD_PATH: ${{ steps.artifactory_upload.outputs.ARTIFACTORY_LAST_BUILD_PATH }}

env:
BUILD_NAME: "hidrive_next-snapshot"

Expand All @@ -175,14 +179,15 @@ jobs:
jf rt ping

- name: Upload build to artifactory
id: artifactory_upload
run: |
# PR builds are stored in a separate directory as "dev/pr/hidrive-next-pr-<number>.zip"
# Push to "ionos-dev" branch is stored as "dev/hidrive-next-<ncVersion>.zip"

ARTIFACTORY_STAGE_PREFIX="dev"

# set ARTIFACTORY_STAGE_PREFIX=stable on ionos-stable branch
if [ "${{ github.ref_name }}" == "ionos-stable" ]; then
if [ ${{ github.ref_name }} == "ionos-stable" ]; then
ARTIFACTORY_STAGE_PREFIX="stable"
fi

Expand All @@ -202,6 +207,8 @@ jobs:
--target-props "hdnext.nc_version=${{ needs.hidrive-next-build.outputs.NC_VERSION }};vcs.branch=${{ github.ref }};vcs.revision=${{ github.sha }}" \
$PATH_TO_LATEST_ARTIFACT

echo "ARTIFACTORY_LAST_BUILD_PATH=${PATH_TO_LATEST_ARTIFACT}" >> $GITHUB_OUTPUT

- name: Show changes on failure
if: failure()
run: |
Expand Down Expand Up @@ -264,3 +271,59 @@ jobs:
if: failure()
run: |
exit 1 # make it red to grab attention


trigger-remote-dev-worflow:
runs-on: self-hosted

name: Trigger remote workflow
needs: [ hidrive-next-build, upload-to-artifactory ]
# Trigger remote build on "ionos-dev|ionos-stable" branch *push* defined in the on:push:branches
if: github.event_name == 'push' && ( github.ref_name == 'ionos-dev' || github.ref_name == 'ionos-stable' )
steps:
- name: Trigger remote workflow
run: |
# Enable command echo
set -x

# The 'ionos-dev' branch will trigger remote "dev" branch workflow
GITLAB_BRANCH="dev"

# set ARTIFACTORY_STAGE_PREFIX=stable on ionos-stable branch
if [ ${{ github.ref_name }} == "ionos-stable" ]; then
GITLAB_BRANCH="stable"
fi

# Call webhook
curl \
--silent \
--insecure \
--request POST \
--fail-with-body \
-o response.json \
--form token=${{ secrets.GITLAB_TOKEN }} \
--form ref="${GITLAB_BRANCH}" \
--form "variables[GITHUB_SHA]=${{ github.sha }}" \
--form "variables[ARTIFACTORY_LAST_BUILD_PATH]=${{ needs.upload-to-artifactory.outputs.ARTIFACTORY_LAST_BUILD_PATH }}" \
--form "variables[NC_VERSION]=${{ needs.hidrive-next-build.outputs.NC_VERSION }}" \
--form "variables[BUILD_ID]=${{ github.run_id }}" \
"${{ secrets.GITLAB_TRIGGER_URL }}" || ( RETCODE="$?"; jq . response.json; exit "$RETCODE" )

# Disable command echo
set +x

# Print and parse json
# jq . response.json
echo "json<<END" >> $GITHUB_OUTPUT
cat response.json >> $GITHUB_OUTPUT
echo "END" >> $GITHUB_OUTPUT
echo "web_url<<END" >> $GITHUB_OUTPUT
cat response.json | jq --raw-output '.web_url' >> $GITHUB_OUTPUT
echo "END" >> $GITHUB_OUTPUT

- name: Show changes on failure
if: failure()
run: |
git status
git --no-pager diff
exit 1 # make it red to grab attention
Loading