|
51 | 51 | outputs: |
52 | 52 | apps-to-build: ${{ steps.detect.outputs.apps-to-build }} |
53 | 53 | external-apps-matrix: ${{ steps.set-matrix.outputs.matrix }} |
54 | | - has-changes: ${{ steps.detect.outputs.has-changes }} |
55 | 54 | steps: |
56 | 55 | - name: Checkout repository |
57 | 56 | uses: actions/checkout@v5 |
@@ -592,30 +591,18 @@ jobs: |
592 | 591 | exit 1 |
593 | 592 | fi |
594 | 593 |
|
595 | | - # Set has-changes based on whether we have apps to build |
596 | | - if [ "$APPS_TO_BUILD_COUNT" -eq 0 ]; then |
597 | | - HAS_CHANGES="false" |
598 | | - echo "ℹ️ No apps need building" |
599 | | - else |
600 | | - HAS_CHANGES="true" |
601 | | - echo "✓ $APPS_TO_BUILD_COUNT app(s) will check cache and build if needed" |
602 | | - fi |
603 | | -
|
604 | 594 | # Output app list with SHAs for the build job to use |
605 | 595 | # Use proper multiline output format for GitHub Actions |
606 | 596 | echo "apps-to-build<<EOF" >> $GITHUB_OUTPUT |
607 | 597 | echo "$APPS_TO_BUILD" >> $GITHUB_OUTPUT |
608 | 598 | echo "EOF" >> $GITHUB_OUTPUT |
609 | 599 |
|
610 | | - echo "has-changes=$HAS_CHANGES" >> $GITHUB_OUTPUT |
611 | | -
|
612 | 600 | echo "" |
613 | 601 | echo "Build jobs will check cache and skip if cached build exists" |
614 | 602 |
|
615 | 603 | build-external-apps: |
616 | 604 | runs-on: ubuntu-latest |
617 | 605 | needs: prepare-matrix |
618 | | - if: needs.prepare-matrix.outputs.has-changes != 'false' |
619 | 606 |
|
620 | 607 | permissions: |
621 | 608 | contents: read |
@@ -734,9 +721,6 @@ jobs: |
734 | 721 | build-artifact: |
735 | 722 | runs-on: ubuntu-latest |
736 | 723 | needs: [prepare-matrix, build-external-apps] |
737 | | - if: | |
738 | | - always() && |
739 | | - (needs.prepare-matrix.outputs.has-changes != 'false') |
740 | 724 |
|
741 | 725 | permissions: |
742 | 726 | contents: read |
@@ -873,10 +857,7 @@ jobs: |
873 | 857 | upload-to-artifactory: |
874 | 858 | runs-on: self-hosted |
875 | 859 | # Upload the artifact to the Artifactory repository on PR *OR* on "ionos-dev|ionos-stable" branch push defined in the on:push:branches |
876 | | - if: | |
877 | | - always() && |
878 | | - needs.build-artifact.result == 'success' && |
879 | | - (github.event_name == 'pull_request' || github.ref_name == 'ionos-dev' || github.ref_name == 'ionos-stable') |
| 860 | + if: github.event_name == 'pull_request' || github.ref_name == 'ionos-dev' || github.ref_name == 'ionos-stable' |
880 | 861 |
|
881 | 862 | name: Push to artifactory |
882 | 863 | needs: [prepare-matrix, build-external-apps, build-artifact] |
@@ -969,4 +950,123 @@ jobs: |
969 | 950 | run: | |
970 | 951 | git status |
971 | 952 | git --no-pager diff |
972 | | - exit 1 |
| 953 | + exit 1 # make it red to grab attention |
| 954 | +
|
| 955 | + nextcloud-workspace-artifact-to-ghcr_io: |
| 956 | + runs-on: ubuntu-latest |
| 957 | + |
| 958 | + permissions: |
| 959 | + contents: read |
| 960 | + packages: write |
| 961 | + |
| 962 | + name: Push artifact to ghcr.io |
| 963 | + needs: [prepare-matrix, build-external-apps, build-artifact] |
| 964 | + |
| 965 | + steps: |
| 966 | + - name: Download artifact zip |
| 967 | + uses: actions/download-artifact@v5 |
| 968 | + with: |
| 969 | + name: nextcloud_workspace_build_artifact |
| 970 | + |
| 971 | + - name: Log in to the Container registry |
| 972 | + uses: docker/login-action@v3 |
| 973 | + with: |
| 974 | + registry: ${{ env.REGISTRY }} |
| 975 | + username: ${{ github.actor }} |
| 976 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 977 | + |
| 978 | + - name: Extract metadata (tags, labels) for Docker |
| 979 | + id: meta |
| 980 | + uses: docker/metadata-action@v5 |
| 981 | + with: |
| 982 | + images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" |
| 983 | + |
| 984 | + - name: Create Dockerfile |
| 985 | + run: | |
| 986 | + cat >Dockerfile << EOF |
| 987 | + FROM busybox as builder |
| 988 | + COPY ./${{ env.TARGET_PACKAGE_NAME }} / |
| 989 | + WORKDIR /builder |
| 990 | + RUN unzip /${{ env.TARGET_PACKAGE_NAME }} -d /builder |
| 991 | +
|
| 992 | + FROM scratch |
| 993 | + WORKDIR /app |
| 994 | + VOLUME /app |
| 995 | + COPY --from=builder /builder /app |
| 996 | + EOF |
| 997 | +
|
| 998 | + - name: Build and push Docker image |
| 999 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 1000 | + with: |
| 1001 | + context: . |
| 1002 | + push: true |
| 1003 | + tags: ${{ steps.meta.outputs.tags }} |
| 1004 | + labels: ${{ steps.meta.outputs.labels }} |
| 1005 | + |
| 1006 | + - name: Show changes on failure |
| 1007 | + if: failure() |
| 1008 | + run: | |
| 1009 | + echo "Git status:" |
| 1010 | + git status |
| 1011 | + echo "Git diff:" |
| 1012 | + git diff |
| 1013 | + exit 1 # make it red to grab attention |
| 1014 | +
|
| 1015 | + trigger-remote-dev-worflow: |
| 1016 | + runs-on: self-hosted |
| 1017 | + |
| 1018 | + name: Trigger remote workflow |
| 1019 | + needs: [ build-artifact, upload-to-artifactory ] |
| 1020 | + # Trigger remote build on "ionos-dev|ionos-stable" branch *push* defined in the on:push:branches |
| 1021 | + if: github.event_name == 'push' && ( github.ref_name == 'ionos-dev' || github.ref_name == 'ionos-stable' ) |
| 1022 | + steps: |
| 1023 | + - name: Trigger remote workflow |
| 1024 | + run: | |
| 1025 | + # Enable command echo for debugging purposes |
| 1026 | + set -x |
| 1027 | +
|
| 1028 | + # Determine build type based on branch: |
| 1029 | + # - 'ionos-dev' branch triggers 'dev' build type |
| 1030 | + # - 'ionos-stable' branch triggers 'stable' build type |
| 1031 | + BUILD_TYPE="dev" |
| 1032 | +
|
| 1033 | + # Override build type for stable branch |
| 1034 | + if [ "${{ github.ref_name }}" == "ionos-stable" ]; then |
| 1035 | + BUILD_TYPE="stable" |
| 1036 | + fi |
| 1037 | +
|
| 1038 | + # Trigger GitLab pipeline via webhook with build artifacts and metadata |
| 1039 | + # Passes GitHub context variables to remote GitLab workflow |
| 1040 | + curl \ |
| 1041 | + --silent \ |
| 1042 | + --insecure \ |
| 1043 | + --request POST \ |
| 1044 | + --fail-with-body \ |
| 1045 | + -o response.json \ |
| 1046 | + --form token=${{ secrets.GITLAB_TOKEN }} \ |
| 1047 | + --form ref="stable" \ |
| 1048 | + --form "variables[GITHUB_SHA]=${{ github.sha }}" \ |
| 1049 | + --form "variables[ARTIFACTORY_LAST_BUILD_PATH]=${{ needs.upload-to-artifactory.outputs.ARTIFACTORY_LAST_BUILD_PATH }}" \ |
| 1050 | + --form "variables[NC_VERSION]=${{ needs.build-artifact.outputs.NC_VERSION }}" \ |
| 1051 | + --form "variables[BUILD_ID]=${{ github.run_id }}" \ |
| 1052 | + --form "variables[BUILD_TYPE]=${BUILD_TYPE}" \ |
| 1053 | + "${{ secrets.GITLAB_TRIGGER_URL }}" || ( RETCODE="$?"; jq . response.json; exit "$RETCODE" ) |
| 1054 | +
|
| 1055 | + # Disable command echo |
| 1056 | + set +x |
| 1057 | +
|
| 1058 | + # Print and parse json |
| 1059 | + # jq . response.json |
| 1060 | + echo "json<<END" >> $GITHUB_OUTPUT |
| 1061 | + cat response.json >> $GITHUB_OUTPUT |
| 1062 | + echo "END" >> $GITHUB_OUTPUT |
| 1063 | + echo "web_url<<END" >> $GITHUB_OUTPUT |
| 1064 | + cat response.json | jq --raw-output '.web_url' >> $GITHUB_OUTPUT |
| 1065 | + echo "END" >> $GITHUB_OUTPUT |
| 1066 | +
|
| 1067 | + - name: Show changes on failure |
| 1068 | + if: failure() |
| 1069 | + run: | |
| 1070 | + git status |
| 1071 | + git --no-pager diff |
| 1072 | + exit 1 # make it red to grab attention |
0 commit comments