diff --git a/.github/workflows/hidrive-next-build.yml b/.github/workflows/hidrive-next-build.yml index 207972ef05527..2d17deb4a380f 100644 --- a/.github/workflows/hidrive-next-build.yml +++ b/.github/workflows/hidrive-next-build.yml @@ -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" @@ -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" @@ -175,6 +179,7 @@ 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-.zip" # Push to "ionos-dev" branch is stored as "dev/hidrive-next-.zip" @@ -182,7 +187,7 @@ jobs: 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 @@ -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: | @@ -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<> $GITHUB_OUTPUT + cat response.json >> $GITHUB_OUTPUT + echo "END" >> $GITHUB_OUTPUT + echo "web_url<> $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