From 17e0eda248ee3add0b0a2c52fa6cd1033e57801a Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 16 Nov 2022 17:13:30 +0100 Subject: [PATCH] Use reusable workflows from a different repository --- .github/workflows/action_branch.yml | 32 +- .github/workflows/action_pull_request.yml | 32 +- .github/workflows/action_schedule.yml | 32 +- .github/workflows/docker-multistage-build.yml | 199 ------------ .../workflows/docker-multistage-configure.yml | 304 ------------------ .../docker-multistage-push-manifest.yml | 122 ------- .github/workflows/params.yml | 26 +- 7 files changed, 46 insertions(+), 701 deletions(-) delete mode 100644 .github/workflows/docker-multistage-build.yml delete mode 100644 .github/workflows/docker-multistage-configure.yml delete mode 100644 .github/workflows/docker-multistage-push-manifest.yml diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml index 7bd9466..7ec9a7b 100644 --- a/.github/workflows/action_branch.yml +++ b/.github/workflows/action_branch.yml @@ -32,21 +32,19 @@ jobs: # ----------------------------------------------------------------------------------------------- configure: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: true can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} versions: ${{ needs.params.outputs.versions }} refs: ${{ needs.params.outputs.refs }} - fields_build: ${{ needs.params.outputs.fields_build }} - fields_deploy: ${{ needs.params.outputs.fields_deploy }} secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} configure-awskops: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: true can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} @@ -60,7 +58,7 @@ jobs: configure-awshelm: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: true can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} @@ -79,7 +77,7 @@ jobs: build-base: needs: - configure - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -98,7 +96,7 @@ jobs: needs: - configure - build-base - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -117,7 +115,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -136,7 +134,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -155,7 +153,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -174,7 +172,7 @@ jobs: needs: - configure - build-aws - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -239,7 +237,7 @@ jobs: needs: - configure - build-base - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -254,7 +252,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -269,7 +267,7 @@ jobs: needs: - configure - build-infra - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -284,7 +282,7 @@ jobs: needs: - configure - build-azure - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -299,7 +297,7 @@ jobs: needs: - configure - build-aws - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -314,7 +312,7 @@ jobs: needs: - configure - build-awsk8s - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml index 4d124a9..1b7a124 100644 --- a/.github/workflows/action_pull_request.yml +++ b/.github/workflows/action_pull_request.yml @@ -27,21 +27,19 @@ jobs: # ----------------------------------------------------------------------------------------------- configure: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && (github.event.pull_request.user.login != 'cytopia')) }} can_deploy: false versions: ${{ needs.params.outputs.versions }} refs: ${{ needs.params.outputs.refs }} - fields_build: ${{ needs.params.outputs.fields_build }} - fields_deploy: ${{ needs.params.outputs.fields_deploy }} secrets: dockerhub_username: "" dockerhub_password: "" configure-awskops: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && (github.event.pull_request.user.login != 'cytopia')) }} can_deploy: false @@ -55,7 +53,7 @@ jobs: configure-awshelm: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && (github.event.pull_request.user.login != 'cytopia')) }} can_deploy: false @@ -74,7 +72,7 @@ jobs: build-base: needs: - configure - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -93,7 +91,7 @@ jobs: needs: - configure - build-base - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -112,7 +110,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -131,7 +129,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -150,7 +148,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -169,7 +167,7 @@ jobs: needs: - configure - build-aws - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -234,7 +232,7 @@ jobs: needs: - configure - build-base - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -249,7 +247,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -264,7 +262,7 @@ jobs: needs: - configure - build-infra - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -279,7 +277,7 @@ jobs: needs: - configure - build-azure - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -294,7 +292,7 @@ jobs: needs: - configure - build-aws - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -309,7 +307,7 @@ jobs: needs: - configure - build-awsk8s - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} diff --git a/.github/workflows/action_schedule.yml b/.github/workflows/action_schedule.yml index 74a5a5b..7e7b147 100644 --- a/.github/workflows/action_schedule.yml +++ b/.github/workflows/action_schedule.yml @@ -29,21 +29,19 @@ jobs: # ----------------------------------------------------------------------------------------------- configure: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: true can_deploy: true versions: ${{ needs.params.outputs.versions }} refs: ${{ needs.params.outputs.refs }} - fields_build: ${{ needs.params.outputs.fields_build }} - fields_deploy: ${{ needs.params.outputs.fields_deploy }} secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} configure-awskops: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: true can_deploy: true @@ -57,7 +55,7 @@ jobs: configure-awshelm: needs: [params] - uses: ./.github/workflows/docker-multistage-configure.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-configure.yml@master with: enabled: true can_deploy: true @@ -76,7 +74,7 @@ jobs: build-base: needs: - configure - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -95,7 +93,7 @@ jobs: needs: - configure - build-base - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -114,7 +112,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -133,7 +131,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -152,7 +150,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -171,7 +169,7 @@ jobs: needs: - configure - build-aws - uses: ./.github/workflows/docker-multistage-build.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} @@ -236,7 +234,7 @@ jobs: needs: - configure - build-base - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -251,7 +249,7 @@ jobs: needs: - configure - build-tools - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -266,7 +264,7 @@ jobs: needs: - configure - build-infra - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -281,7 +279,7 @@ jobs: needs: - configure - build-azure - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -296,7 +294,7 @@ jobs: needs: - configure - build-aws - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -311,7 +309,7 @@ jobs: needs: - configure - build-awsk8s - uses: ./.github/workflows/docker-multistage-push-manifest.yml + uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} diff --git a/.github/workflows/docker-multistage-build.yml b/.github/workflows/docker-multistage-build.yml deleted file mode 100644 index 976de2c..0000000 --- a/.github/workflows/docker-multistage-build.yml +++ /dev/null @@ -1,199 +0,0 @@ ---- -name: "Build multistage docker images (multi -flavours, -versions, -architectures)" - -on: - workflow_call: - ### - ### Variables - ### - inputs: - matrix: - description: 'The build matrix' - required: true - type: string - stage: - description: 'The stage to build (Examples: base, mods, prod or work).' - required: true - type: string - stage_prev: - description: 'The previous stage (used for downloading previous artifact).' - required: true - type: string - artifact_prefix: - description: 'Unique artifact name prefix (to avoid overriding existing artifcats during parallel runs).' - required: true - type: string - has_refs: - description: 'The ref build matrix as JSON string (list of git refs to build/deploy).' - required: true - type: boolean - run_tests: - description: 'Dertermines whether we run integration tests or not.' - required: true - type: boolean - upload_artifact: - description: 'Dertermines whether we upload the artifact not.' - required: true - type: boolean - push_image: - description: 'Push docker image after build (and test if ran)?' - required: false - type: boolean - default: false - pull_base_image: - description: 'Pull Docker base image before building?' - required: false - type: boolean - default: false - ### - ### Secrets - ### - secrets: - dockerhub_username: - description: 'The username for Dockerhub.' - required: true - dockerhub_password: - description: 'The password for Dockerhub.' - required: true - -jobs: - # ----------------------------------------------------------------------------------------------- - # JOB: BUILD - # ----------------------------------------------------------------------------------------------- - build: - name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }} (${{ matrix.ARCH }}) ${{ matrix.REFS }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: ${{ fromJson(inputs.matrix) }} - steps: - - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: "[SETUP] Checkout repository (current)" - uses: actions/checkout@v3 - with: - fetch-depth: 0 - if: ${{ !inputs.has_refs }} - - - name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})" - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ matrix.REFS }} - if: ${{ inputs.has_refs }} - - - name: "[SETUP] Install QEMU environment" - uses: docker/setup-qemu-action@v2 - id: qemu - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: "[SETUP] Set artifact names" - id: set-artifact-name - run: | - VERSION="$( echo "${{ matrix.VERSION }}" )" - ARCH="$( echo "${{ matrix.ARCH }}" | sed 's|/|-|g' )" - - NAME_PREV="${{ inputs.artifact_prefix }}-${VERSION}-${ARCH}-${{ inputs.stage_prev }}" - NAME_CURR="${{ inputs.artifact_prefix }}-${VERSION}-${ARCH}-${{ inputs.stage }}" - echo "prev=${NAME_PREV}" >> $GITHUB_OUTPUT - echo "curr=${NAME_CURR}" >> $GITHUB_OUTPUT - - - name: "[SETUP] Determine Docker tag" - id: tag - uses: cytopia/docker-tag-action@v0.4.22 - - # https://github.com/alpinelinux/docker-alpine/issues/98 - - name: "[SETUP] Fix Docker IP forwarding" - run: | - sysctl net.ipv4.ip_forward - sudo sysctl -w net.ipv4.ip_forward=1 - sudo systemctl restart docker - - - # ------------------------------------------------------------ - # Artifact Import - # ------------------------------------------------------------ - - name: "[Artifact Load] Download previously built image" - uses: cytopia/download-artifact-retry-action@v0.1.4 - with: - name: ${{ steps.set-artifact-name.outputs.prev }} - if: ${{ inputs.stage_prev != '' }} - - - name: "[Artifact Load] Import previously built image" - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make load INFILE=${{ steps.set-artifact-name.outputs.prev }} - if: ${{ inputs.stage_prev != '' }} - - - # ------------------------------------------------------------ - # Build - # ------------------------------------------------------------ - - name: Pull - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make docker-pull-base-image VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} - if: ${{ inputs.pull_base_image }} - - - name: Build - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make build VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} - - - # ------------------------------------------------------------ - # Test - # ------------------------------------------------------------ - - name: Test - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make test VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} - if: ${{ inputs.run_tests }} - - - # ------------------------------------------------------------ - # Push - # ------------------------------------------------------------ - - name: Docker Tag - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make tag VERSION="${{ matrix.VERSION }}" STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} TAG=${{ steps.tag.outputs.docker-tag }} - - - name: Docker login - uses: docker/login-action@v2 - with: - username: ${{ secrets.dockerhub_username }} - password: ${{ secrets.dockerhub_password }} - if: ${{ inputs.push_image }} - - - name: Docker push - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make push VERSION="${{ matrix.version }}" STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.flavour }} ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} - if: ${{ inputs.push_image }} - - - # ------------------------------------------------------------ - # Artifact Export - # ------------------------------------------------------------ - - name: "[Artifact Save] Upload built artifact" - uses: cytopia/upload-artifact-retry-action@v0.1.6 - with: - name: ${{ steps.set-artifact-name.outputs.curr }} - path: ${{ steps.set-artifact-name.outputs.curr }} - pre_command: | - make save-verify VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} OUTFILE=${{ steps.set-artifact-name.outputs.curr }} INFILE=${{ steps.set-artifact-name.outputs.curr }} - post_command: | - make load INFILE={{download_path}} - if: ${{ inputs.upload_artifact }} diff --git a/.github/workflows/docker-multistage-configure.yml b/.github/workflows/docker-multistage-configure.yml deleted file mode 100644 index ac9742c..0000000 --- a/.github/workflows/docker-multistage-configure.yml +++ /dev/null @@ -1,304 +0,0 @@ ---- -name: "Configure multistage docker images (multi -flavours, -versions, -architectures)" - -on: - workflow_call: - ### - ### Input Variables - ### - inputs: - versions: - description: 'The JSON string for versions. ( list of objects: [{NAME, VERSION[], ARCH[]}] )' - required: true - type: string - refs: - description: 'The JSON string for refs. ( object: {BRANCH, NUM_LATEST_TAGS} )' - required: true - type: string - fields_build: - description: 'The JSON string for build fields to extract' - required: true - type: string - fields_deploy: - description: 'The JSON string for deploy fields to extract' - required: true - type: string - enabled: - description: 'Determines whether this workflow is enabled at all (will run or skip).' - required: true - type: boolean - can_deploy: - description: 'Determines whether this workflow can deploy (login and push).' - required: true - type: boolean - - ### - ### Input Secrets - ### - secrets: - dockerhub_username: - description: 'The username for Dockerhub.' - required: false - dockerhub_password: - description: 'The password for Dockerhub.' - required: false - - ### - ### Outputs - ### - outputs: - # Repeat input variables - versions: - description: "(string) Copied from inputs: The JSON string for versions." - value: ${{ jobs.configure.outputs.versions }} - refs: - description: "(string) Copied from inputs: The JSON string for refs." - value: ${{ jobs.configure.outputs.refs }} - # Determined settings (flags) - can_login: - description: "(boolean) Can we login to Dockerhub?" - value: ${{ jobs.configure.outputs.can_login }} - can_push: - description: "(boolean) Can we push to Dockerhub?" - value: ${{ jobs.configure.outputs.can_push }} - # Determined settings (values) - has_refs: - description: "(string) 'true' or 'false' Do we have refs to build?" - value: ${{ jobs.configure.outputs.has_refs }} - matrix_build: - description: "(string) The determined JSON string build matrix." - value: ${{ jobs.configure.outputs.matrix_build }} - matrix_deploy: - description: "(string) The determined JSON string deploy matrix." - value: ${{ jobs.configure.outputs.matrix_deploy }} - artifact_prefix: - description: "(string) The determined unique artifact prefix." - value: ${{ jobs.configure.outputs.artifact_prefix }} - -jobs: - - # ----------------------------------------------------------------------------------------------- - # JOB (1/3): CONFIGURE - # ----------------------------------------------------------------------------------------------- - configure: - name: Configure - if: ${{ inputs.enabled }} - runs-on: ubuntu-latest - - ### - ### Outputs - ### - outputs: - # Copied from inputs - versions: ${{ inputs.versions }} - refs: ${{ inputs.refs }} - # Flags - can_login: ${{ steps.set-login.outputs.can_login }} - can_push: ${{ steps.set-push.outputs.can_push }} - # Settings - has_refs: ${{ steps.set-refs.outputs.has_refs }} - artifact_prefix: ${{ steps.set-artifact-prefix.outputs.prefix }} - # Values - matrix_build: ${{ steps.set-matrix.outputs.matrix_build }} - matrix_deploy: ${{ steps.set-matrix.outputs.matrix_deploy }} - - ### - ### Steps - ### - steps: - - # ------------------------------------------------------------ - # Set flags - # ------------------------------------------------------------ - - ### - ### Can we login to Dockerhub? - ### - - name: "[Set-Output] can_login (Set Docker login capabilities)" - id: set-login - shell: bash - run: | - if [ "${{ env.ENV_USER }}" = '' ] || [ "${{ env.ENV_PASS }}" = '' ]; then - echo "can_login=false" >> $GITHUB_OUTPUT - else - echo "can_login=true" >> $GITHUB_OUTPUT - fi - env: - ENV_USER: ${{ secrets.dockerhub_username }} - ENV_PASS: ${{ secrets.dockerhub_password }} - - ### - ### Can we push to Dockerhub? - ### - - name: "[Set-Output] can_push (Set Docker push capabilities)" - id: set-push - shell: bash - run: | - if [ "${{ steps.set-login.outputs.can_login }}" = "true" ] && [ "${{ inputs.can_deploy }}" = "true" ]; then - echo "can_push=true" >> $GITHUB_OUTPUT - else - echo "can_push=false" >> $GITHUB_OUTPUT - fi - - # ------------------------------------------------------------ - # Set values - # ------------------------------------------------------------ - - ### - ### Do we have refs to build against? - ### - - name: "Evaluate Refs (branches and latest tags)" - id: eval-refs - shell: bash - run: | - DEFAULT_BRANCH="$( echo '${{ inputs.refs }}' | jq -M -c -r '.DEFAULT_BRANCH' )" - BRANCHES="$( echo '${{ inputs.refs }}' | jq -M -c -r '.BRANCHES' )" - NUM_LATEST_TAGS="$( echo '${{ inputs.refs }}' | jq -M -c -r '.NUM_LATEST_TAGS' )" - - echo "default_branch=${DEFAULT_BRANCH}" >> $GITHUB_OUTPUT - echo "branches=${BRANCHES}" >> $GITHUB_OUTPUT - echo "num_latest_tags=${NUM_LATEST_TAGS}" >> $GITHUB_OUTPUT - - echo "DEFAULT_BRANCH=${DEFAULT_BRANCH}" - echo "BRANCHES=${BRANCHES}" - echo "NUM_LATEST_TAGS=${NUM_LATEST_TAGS}" - - ### - ### Set Refs - ### - - name: "[Set-Output] has_refs and ref-matrix" - id: set-refs - uses: cytopia/git-ref-matrix-action@v0.1.13 - with: - repository_default_branch: ${{ steps.eval-refs.outputs.default_branch }} - branches: ${{ steps.eval-refs.outputs.branches }} - num_latest_tags: ${{ steps.eval-refs.outputs.num_latest_tags }} - # Only use refs if the job is a schedule or if the job is schedule and was triggered manually - disable_refs: ${{ !(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} - - ### - ### Unique Artifact prefix - ### - - name: "[Set-Output] artifact_prefix (unique Artifact prefix)" - id: set-artifact-prefix - shell: bash - run: | - PRE_RUN="$( echo '${{ github.run_id }}' )" - PRE_SHA="$( echo '${{ github.sha }}' | md5sum | head -c 10 )" - echo "prefix=${PRE_RUN}-${PRE_SHA}" >> $GITHUB_OUTPUT - - ### - ### Set Build and Deploy Matrix - ### - - name: "[Set-Output] matrix_build and matrix_deploy (Build Matrix & Deploy Matrix)" - id: set-matrix - shell: bash - run: | - FIELDS_BUILD="$( echo '${{ inputs.fields_build }}' | jq -M -c )" - FIELDS_DEPLOY="$( echo '${{ inputs.fields_deploy }}' | jq -M -c )" - VERSIONS="$( echo '${{ inputs.versions }}' | jq -M -c )" - - if [ "${{ steps.set-refs.outputs.has_refs }}" = "true" ]; then - REFS="$( echo '${{ steps.set-refs.outputs.matrix }}' | jq -M -c )" - - # map({NAME: .NAME, VERSION: .VERSION[], FLAVOUR: .FLAVOUR[], ARCH:. ARCH[], ...}) - INNER_STRING="$( echo "${FIELDS_BUILD}" \ - | jq -r '.[] | to_entries[] | "\(.value): .\(.key)[]"' \ - | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' \ - | jq -r '. | join(", ")' )" - OUTER_STRING="$( echo "'map({NAME: .NAME, ${INNER_STRING}, REFS: ${REFS}[]})'" )" - MATRIX_BUILD="$( eval jq -M -c "${OUTER_STRING}" <<<"${VERSIONS}" )" - - # map({NAME: .NAME, VERSION: .VERSION[], FLAVOUR: .FLAVOUR[], ....}) - INNER_STRING="$( echo "${FIELDS_DEPLOY}" \ - | jq -r '.[] | to_entries[] | "\(.value): .\(.key)[]"' \ - | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' \ - | jq -r '. | join(", ")' )" - OUTER_STRING="$( echo "'map({NAME: .NAME, ${INNER_STRING}, REFS: ${REFS}[]})'" )" - MATRIX_DEPLOY="$( eval jq -M -c "${OUTER_STRING}" <<<"${VERSIONS}" )" - - echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT - echo "matrix_deploy=${MATRIX_DEPLOY}" >> $GITHUB_OUTPUT - - else - - # map({NAME: .NAME, VERSION: .VERSION[], FLAVOUR: .FLAVOUR[], ARCH:. ARCH[], ...}) - INNER_STRING="$( echo "${FIELDS_BUILD}" \ - | jq -r '.[] | to_entries[] | "\(.value): .\(.key)[]"' \ - | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' \ - | jq -r '. | join(", ")' )" - OUTER_STRING="$( echo "'map({NAME: .NAME, ${INNER_STRING}})'" )" - MATRIX_BUILD="$( eval jq -M -c "${OUTER_STRING}" <<<"${VERSIONS}" )" - - # map({NAME: .NAME, VERSION: .VERSION[], FLAVOUR: .FLAVOUR[], ....}) - INNER_STRING="$( echo "${FIELDS_DEPLOY}" \ - | jq -r '.[] | to_entries[] | "\(.value): .\(.key)[]"' \ - | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' \ - | jq -r '. | join(", ")' )" - OUTER_STRING="$( echo "'map({NAME: .NAME, ${INNER_STRING}})'" )" - MATRIX_DEPLOY="$( eval jq -M -c "${OUTER_STRING}" <<<"${VERSIONS}" )" - - echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT - echo "matrix_deploy=${MATRIX_DEPLOY}" >> $GITHUB_OUTPUT - fi - - # ------------------------------------------------------------ - # Debug - # ------------------------------------------------------------ - - - name: "[DEBUG] Show GitHub Context" - shell: bash - run: | - echo 'Context | Value' - echo '-------------------------------------|-----------------------------------' - echo 'github.actor | ${{ github.actor }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.repository_owner | ${{ github.repository_owner }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.event.pull_request.user.login | ${{ github.event.pull_request.user.login }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.event_name | ${{ github.event_name }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.ref | ${{ github.ref }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.ref_name | ${{ github.ref_name }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.head_ref | ${{ github.head_ref }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.base_ref | ${{ github.base_ref }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.ref_type | ${{ github.ref_type }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.repository | ${{ github.repository }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.action | ${{ github.action }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.action_ref | ${{ github.action_ref }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.run_id | ${{ github.run_id }}' - echo '-------------------------------------|-----------------------------------' - echo 'github.sha | ${{ github.sha }}' - - - name: "[DEBUG] Show Workflow Inputs" - shell: bash - run: | - echo 'enabled: ${{ inputs.enabled }}' - echo 'can_deploy: ${{ inputs.can_deploy }}' - echo 'versions: ${{ inputs.versions }}' - echo 'refs: ${{ inputs.refs }}' - - - name: "[DEBUG] Show Workflow Outputs" - shell: bash - run: | - # Copied from inputs - echo 'versions: ${{ inputs.versions }}' - echo 'refs: ${{ inputs.refs }}' - # Flags - echo 'can_login: ${{ steps.set-login.outputs.can_login }}' - echo 'can_push: ${{ steps.set-push.outputs.can_push }}' - # Settins - echo 'has_refs: ${{ steps.set-refs.outputs.has_refs }}' - # Values - echo 'artifact_prefix: ${{ steps.set-artifact-prefix.outputs.prefix }}' - echo 'matrix_build: ${{ steps.set-matrix.outputs.matrix_build }}' - echo 'matrix_deploy: ${{ steps.set-matrix.outputs.matrix_deploy }}' diff --git a/.github/workflows/docker-multistage-push-manifest.yml b/.github/workflows/docker-multistage-push-manifest.yml deleted file mode 100644 index b9c7271..0000000 --- a/.github/workflows/docker-multistage-push-manifest.yml +++ /dev/null @@ -1,122 +0,0 @@ ---- -name: Deploy multi-arch image manifests - -on: - workflow_call: - ### - ### Variables - ### - inputs: - matrix: - description: 'The version deploy matrix as JSON string ( list of objects: [{NAME, VERSION[], ARCH[]}] ).' - required: true - type: string - versions: - description: 'The build matrix set via params.yml.' - required: true - type: string - stage: - description: 'The stage to build (Examples: base, mods, prod or work).' - required: true - type: string - can_deploy: - description: 'Determines whether this workflow will also deploy (login and push).' - required: true - type: boolean - has_refs: - description: 'The ref build matrix as JSON string (list of git refs to build/deploy).' - required: true - type: boolean - - - ### - ### Secrets - ### - secrets: - dockerhub_username: - description: 'The username for Dockerhub.' - required: false - dockerhub_password: - description: 'The password for Dockerhub.' - required: false - -jobs: - # ----------------------------------------------------------------------------------------------- - # JOB (3/3): DEPLOY - # ----------------------------------------------------------------------------------------------- - deploy: - name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }} ${{ matrix.REFS }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: ${{ fromJson(inputs.matrix) }} - if: ${{ inputs.can_deploy }} - steps: - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: "[SETUP] Checkout repository (current)" - uses: actions/checkout@v3 - with: - fetch-depth: 0 - if: ${{ !inputs.has_refs }} - - - name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})" - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ matrix.REFS }} - if: ${{ inputs.has_refs }} - - - name: "[SETUP] Setup QEMU environment" - uses: docker/setup-qemu-action@v2 - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: "[SETUP] Determine Docker tag" - id: tag - uses: cytopia/docker-tag-action@v0.4.22 - - - name: "[SETUP] Determine manifest arches" - id: manifest - run: | - ARCHES="$( echo '${{ inputs.versions }}' \ - | jq 'group_by(.NAME, .VERSION, .FLAVOUR, .ARCH)' \ - | jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], FLAVOUR: .[].FLAVOUR[], ARCHES: .[].ARCH|join(",")})' \ - | jq '.[] | select(.NAME=="${{ matrix.NAME }}" and .VERSION=="${{ matrix.VERSION }}" and .FLAVOUR=="${{ matrix.FLAVOUR }}") | .ARCHES' \ - | jq -c -M \ - )" - echo "arches=${ARCHES}" >> $GITHUB_OUTPUT - echo "ARCHES: ${ARCHES}" - - - # ------------------------------------------------------------ - # Login - # ------------------------------------------------------------ - - name: "Login" - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - # ------------------------------------------------------------ - # Create Manifest - # ------------------------------------------------------------ - - name: "[Create Manifest] (${{ steps.manifest.outputs.arches }})" - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make manifest-create VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCHES=${{ steps.manifest.outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }} - - - # ------------------------------------------------------------ - # Deploy Manifest - # ------------------------------------------------------------ - - name: "[Push Manifest] ${{ steps.tag.outputs.docker-tag }}" - uses: cytopia/shell-command-retry-action@v0.1.5 - with: - command: | - make manifest-push VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} TAG=${{ steps.tag.outputs.docker-tag }} diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml index 297ae69..3c95747 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -50,8 +50,6 @@ env: "ARCH": ["linux/amd64", "linux/arm64"] } ] - FIELDS_BUILD: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"ARCH":"ARCH"}]' - FIELDS_DEPLOY: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}]' # Set Refs to build for scheduled jobs REFS: >- @@ -74,12 +72,6 @@ on: refs: description: "Stringified JSON of Refs definition." value: ${{ jobs.params.outputs.refs }} - fields_build: - description: "Stringified JSON of Build fields to extract." - value: ${{ jobs.params.outputs.fields_build }} - fields_deploy: - description: "Stringified JSON of Deploy fields to extract." - value: ${{ jobs.params.outputs.fields_deploy }} jobs: params: @@ -88,22 +80,16 @@ jobs: outputs: versions: ${{ steps.set-json.outputs.versions }} refs: ${{ steps.set-json.outputs.refs }} - fields_build: ${{ steps.set-json.outputs.fields_build }} - fields_deploy: ${{ steps.set-json.outputs.fields_deploy }} steps: - name: "[Set-Output] JSON" id: set-json run: | VERSIONS="$( echo '${{ env.VERSIONS }}' | jq -M -c )" - REFS="$( echo '${{ env.REFS }}' | jq -M -c )" - FIELDS_BUILD="$( echo '${{ env.FIELDS_BUILD }}' | jq -M -c )" - FIELDS_DEPLOY="$( echo '${{ env.FIELDS_DEPLOY }}' | jq -M -c )" + REFS="$( echo '${{ env.REFS }}' | jq -M -c )" echo "versions=${VERSIONS}" >> $GITHUB_OUTPUT echo "refs=${REFS}" >> $GITHUB_OUTPUT - echo "fields_build=${FIELDS_BUILD}" >> $GITHUB_OUTPUT - echo "fields_deploy=${FIELDS_DEPLOY}" >> $GITHUB_OUTPUT - name: "[DEBUG] Show settings'" run: | @@ -116,13 +102,3 @@ jobs: echo '--------------------' echo '${{ steps.set-json.outputs.refs }}' echo - - echo 'Fields (build)' - echo '--------------------' - echo '${{ steps.set-json.outputs.fields_build }}' - echo - - echo 'Fields (deploy)' - echo '--------------------' - echo '${{ steps.set-json.outputs.fields_deploy }}' - echo