diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml index 960257c..7bd9466 100644 --- a/.github/workflows/action_branch.yml +++ b/.github/workflows/action_branch.yml @@ -22,284 +22,224 @@ on: jobs: # ----------------------------------------------------------------------------------------------- - # (1/5) Determine parameter settings + # (1/4) Determine parameter settings # ----------------------------------------------------------------------------------------------- params: uses: ./.github/workflows/params.yml # ----------------------------------------------------------------------------------------------- - # (2/5) Configure Build and Deploy Matrices + # (2/4) Configure Build and Deploy Matrices # ----------------------------------------------------------------------------------------------- configure: needs: [params] - uses: ./.github/workflows/docker-multistage-configure-extra.yml + uses: ./.github/workflows/docker-multistage-configure.yml 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: ${{ (github.repository == 'cytopia/docker-ansible') && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-')) }} - is_scheduled: false + 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 + 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: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"KOPS":"EXTRA"}, {"ARCH":"ARCH"}]' + fields_deploy: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"KOPS":"EXTRA"}]' + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} + + configure-awshelm: + needs: [params] + uses: ./.github/workflows/docker-multistage-configure.yml + 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: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"HELM":"EXTRA"}, {"ARCH":"ARCH"}]' + fields_deploy: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"HELM":"EXTRA"}]' + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} + + # ----------------------------------------------------------------------------------------------- - # (3/5) Build & Test + # (3/4) Build & Test # ----------------------------------------------------------------------------------------------- build-base: needs: - configure - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: true + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: base stage_prev: '' + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-tools: needs: - configure - build-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: tools stage_prev: base + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-aws: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: aws stage_prev: tools + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-azure: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: azure stage_prev: tools + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-infra: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: infra stage_prev: tools + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-awsk8s: needs: - configure - build-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: awsk8s stage_prev: aws + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} # Note: awskops is special build-awskops: needs: - - configure + - configure-awskops - build-awsk8s - uses: ./.github/workflows/docker-multistage-build-kops.yml + uses: ./.github/workflows/docker-multistage-build-extra.yml with: - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true + has_refs: ${{ needs.configure-awskops.outputs.has_refs == 'true' }} + artifact_prefix: ${{ needs.configure-awskops.outputs.artifact_prefix }} upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build_kops }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} pull_base_image: false + push_image: ${{ needs.configure-awskops.outputs.can_login == 'true' && needs.configure-awskops.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure-awskops.outputs.matrix_build }} stage: awskops stage_prev: awsk8s + extra_make_var_name: KOPS + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} # Note: awshelm is special build-awshelm: needs: - - configure + - configure-awshelm - build-awsk8s - uses: ./.github/workflows/docker-multistage-build-helm.yml + uses: ./.github/workflows/docker-multistage-build-extra.yml with: - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true + has_refs: ${{ needs.configure-awshelm.outputs.has_refs == 'true' }} + artifact_prefix: ${{ needs.configure-awshelm.outputs.artifact_prefix }} upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build_helm }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} pull_base_image: false + push_image: ${{ needs.configure-awshelm.outputs.can_login == 'true' && needs.configure-awshelm.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure-awshelm.outputs.matrix_build }} stage: awshelm stage_prev: awsk8s - - # ----------------------------------------------------------------------------------------------- - # (4/5) Push images - # ----------------------------------------------------------------------------------------------- - push-base: - needs: - - configure - - build-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: base - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-tools: - needs: - - configure - - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: tools + extra_make_var_name: HELM secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - push-infra: - needs: - - configure - - build-infra - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: infra - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-azure: - needs: - - configure - - build-azure - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: azure - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-aws: - needs: - - configure - - build-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: aws - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-awsk8s: - needs: - - configure - - build-awsk8s - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awsk8s - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - # Note: awskops is special - push-awskops: - needs: - - configure - - build-awskops - uses: ./.github/workflows/docker-multistage-push-image-kops.yml - with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build_kops }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awskops - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - # Note: awshelm is special - push-awshelm: - needs: - - configure - - build-awshelm - uses: ./.github/workflows/docker-multistage-push-image-helm.yml - with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build_helm }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awshelm - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} # ----------------------------------------------------------------------------------------------- - # (5/5) Push Manifests + # (4/4) Push Manifests # ----------------------------------------------------------------------------------------------- manifest-base: needs: - configure - - push-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-base + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -313,8 +253,8 @@ jobs: manifest-tools: needs: - configure - - push-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-tools + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -328,8 +268,8 @@ jobs: manifest-infra: needs: - configure - - push-infra - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-infra + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -343,8 +283,8 @@ jobs: manifest-azure: needs: - configure - - push-azure - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-azure + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -358,8 +298,8 @@ jobs: manifest-aws: needs: - configure - - push-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-aws + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -373,8 +313,8 @@ jobs: manifest-awsk8s: needs: - configure - - push-awsk8s - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-awsk8s + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -388,14 +328,14 @@ jobs: # Note: awskops is special manifest-awskops: needs: - - configure - - push-awskops + - configure-awskops + - build-awskops uses: ./.github/workflows/docker-multistage-push-manifest-kops.yml with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_deploy_kops }} - versions: ${{ needs.configure.outputs.versions }} + can_deploy: ${{ needs.configure-awskops.outputs.can_login == 'true' && needs.configure-awskops.outputs.can_push == 'true' }} + has_refs: ${{ needs.configure-awskops.outputs.has_refs == 'true' }} + matrix: ${{ needs.configure-awskops.outputs.matrix_deploy }} + versions: ${{ needs.configure-awskops.outputs.versions }} stage: awskops secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -404,14 +344,14 @@ jobs: # Note: awshelm is special manifest-awshelm: needs: - - configure - - push-awshelm + - configure-awshelm + - build-awshelm uses: ./.github/workflows/docker-multistage-push-manifest-helm.yml with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_deploy_helm }} - versions: ${{ needs.configure.outputs.versions }} + can_deploy: ${{ needs.configure-awshelm.outputs.can_login == 'true' && needs.configure-awshelm.outputs.can_push == 'true' }} + has_refs: ${{ needs.configure-awshelm.outputs.has_refs == 'true' }} + matrix: ${{ needs.configure-awshelm.outputs.matrix_deploy }} + versions: ${{ needs.configure-awshelm.outputs.versions }} stage: awshelm secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml index a72f86e..4d124a9 100644 --- a/.github/workflows/action_pull_request.yml +++ b/.github/workflows/action_pull_request.yml @@ -15,7 +15,7 @@ on: jobs: # ----------------------------------------------------------------------------------------------- - # (1/5) Determine parameter settings + # (1/4) Determine parameter settings # ----------------------------------------------------------------------------------------------- params: uses: ./.github/workflows/params.yml @@ -23,280 +23,220 @@ jobs: if: github.event.pull_request.head.repo.fork # ----------------------------------------------------------------------------------------------- - # (2/5) Configure Build and Deploy Matrices + # (2/4) Configure Build and Deploy Matrices # ----------------------------------------------------------------------------------------------- configure: needs: [params] - uses: ./.github/workflows/docker-multistage-configure-extra.yml + uses: ./.github/workflows/docker-multistage-configure.yml 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 - is_scheduled: 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 + 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: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"KOPS":"EXTRA"}, {"ARCH":"ARCH"}]' + fields_deploy: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"KOPS":"EXTRA"}]' + secrets: + dockerhub_username: "" + dockerhub_password: "" + + configure-awshelm: + needs: [params] + uses: ./.github/workflows/docker-multistage-configure.yml + 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: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"HELM":"EXTRA"}, {"ARCH":"ARCH"}]' + fields_deploy: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"HELM":"EXTRA"}]' + secrets: + dockerhub_username: "" + dockerhub_password: "" + + # ----------------------------------------------------------------------------------------------- - # (3/5) Build & Test + # (3/4) Build & Test # ----------------------------------------------------------------------------------------------- build-base: needs: - configure - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: true + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: base stage_prev: '' + secrets: + dockerhub_username: "" + dockerhub_password: "" build-tools: needs: - configure - build-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: tools stage_prev: base + secrets: + dockerhub_username: "" + dockerhub_password: "" build-aws: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: aws stage_prev: tools + secrets: + dockerhub_username: "" + dockerhub_password: "" build-azure: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: azure stage_prev: tools + secrets: + dockerhub_username: "" + dockerhub_password: "" build-infra: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: infra stage_prev: tools + secrets: + dockerhub_username: "" + dockerhub_password: "" build-awsk8s: needs: - configure - build-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: awsk8s stage_prev: aws + secrets: + dockerhub_username: "" + dockerhub_password: "" # Note: awskops is special build-awskops: needs: - - configure + - configure-awskops - build-awsk8s - uses: ./.github/workflows/docker-multistage-build-kops.yml + uses: ./.github/workflows/docker-multistage-build-extra.yml with: - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true + has_refs: ${{ needs.configure-awskops.outputs.has_refs == 'true' }} + artifact_prefix: ${{ needs.configure-awskops.outputs.artifact_prefix }} upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build_kops }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} pull_base_image: false + push_image: ${{ needs.configure-awskops.outputs.can_login == 'true' && needs.configure-awskops.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure-awskops.outputs.matrix_build }} stage: awskops stage_prev: awsk8s + extra_make_var_name: KOPS + secrets: + dockerhub_username: "" + dockerhub_password: "" # Note: awshelm is special build-awshelm: needs: - - configure + - configure-awshelm - build-awsk8s - uses: ./.github/workflows/docker-multistage-build-helm.yml + uses: ./.github/workflows/docker-multistage-build-extra.yml with: - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true + has_refs: ${{ needs.configure-awshelm.outputs.has_refs == 'true' }} + artifact_prefix: ${{ needs.configure-awshelm.outputs.artifact_prefix }} upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build_helm }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} pull_base_image: false + push_image: ${{ needs.configure-awshelm.outputs.can_login == 'true' && needs.configure-awshelm.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure-awshelm.outputs.matrix_build }} stage: awshelm stage_prev: awsk8s - - # ----------------------------------------------------------------------------------------------- - # (4/5) Push images - # ----------------------------------------------------------------------------------------------- - push-base: - needs: - - configure - - build-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.yml@master - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: base - secrets: - dockerhub_username: "" - dockerhub_password: "" - - push-tools: - needs: - - configure - - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.yml@master - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: tools - secrets: - dockerhub_username: "" - dockerhub_password: "" - - push-infra: - needs: - - configure - - build-infra - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.yml@master - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: infra - secrets: - dockerhub_username: "" - dockerhub_password: "" - - push-azure: - needs: - - configure - - build-azure - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.yml@master - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: azure - secrets: - dockerhub_username: "" - dockerhub_password: "" - - push-aws: - needs: - - configure - - build-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.yml@master - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: aws - secrets: - dockerhub_username: "" - dockerhub_password: "" - - push-awsk8s: - needs: - - configure - - build-awsk8s - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.yml@master - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awsk8s + extra_make_var_name: HELM secrets: dockerhub_username: "" dockerhub_password: "" - # Note: awskops is special - push-awskops: - needs: - - configure - - build-awskops - uses: ./.github/workflows/docker-multistage-push-image-kops.yml - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build_kops }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awskops - secrets: - dockerhub_username: "" - dockerhub_password: "" - - # Note: awshelm is special - push-awshelm: - needs: - - configure - - build-awshelm - uses: ./.github/workflows/docker-multistage-push-image-helm.yml - with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build_helm }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awshelm - secrets: - dockerhub_username: "" - dockerhub_password: "" # ----------------------------------------------------------------------------------------------- - # (5/5) Push Manifests + # (4/4) Push Manifests # ----------------------------------------------------------------------------------------------- manifest-base: needs: - configure - - push-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-base + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: - can_deploy: false + can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} matrix: ${{ needs.configure.outputs.matrix_deploy }} versions: ${{ needs.configure.outputs.versions }} @@ -308,10 +248,10 @@ jobs: manifest-tools: needs: - configure - - push-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-tools + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: - can_deploy: false + can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} matrix: ${{ needs.configure.outputs.matrix_deploy }} versions: ${{ needs.configure.outputs.versions }} @@ -323,10 +263,10 @@ jobs: manifest-infra: needs: - configure - - push-infra - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-infra + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: - can_deploy: false + can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} matrix: ${{ needs.configure.outputs.matrix_deploy }} versions: ${{ needs.configure.outputs.versions }} @@ -338,10 +278,10 @@ jobs: manifest-azure: needs: - configure - - push-azure - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-azure + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: - can_deploy: false + can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} matrix: ${{ needs.configure.outputs.matrix_deploy }} versions: ${{ needs.configure.outputs.versions }} @@ -353,10 +293,10 @@ jobs: manifest-aws: needs: - configure - - push-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-aws + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: - can_deploy: false + can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} matrix: ${{ needs.configure.outputs.matrix_deploy }} versions: ${{ needs.configure.outputs.versions }} @@ -368,10 +308,10 @@ jobs: manifest-awsk8s: needs: - configure - - push-awsk8s - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-awsk8s + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: - can_deploy: false + can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} matrix: ${{ needs.configure.outputs.matrix_deploy }} versions: ${{ needs.configure.outputs.versions }} @@ -383,14 +323,14 @@ jobs: # Note: awskops is special manifest-awskops: needs: - - configure - - push-awskops + - configure-awskops + - build-awskops uses: ./.github/workflows/docker-multistage-push-manifest-kops.yml with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_deploy_kops }} - versions: ${{ needs.configure.outputs.versions }} + can_deploy: ${{ needs.configure-awskops.outputs.can_login == 'true' && needs.configure-awskops.outputs.can_push == 'true' }} + has_refs: ${{ needs.configure-awskops.outputs.has_refs == 'true' }} + matrix: ${{ needs.configure-awskops.outputs.matrix_deploy }} + versions: ${{ needs.configure-awskops.outputs.versions }} stage: awskops secrets: dockerhub_username: "" @@ -399,14 +339,14 @@ jobs: # Note: awshelm is special manifest-awshelm: needs: - - configure - - push-awshelm + - configure-awshelm + - build-awshelm uses: ./.github/workflows/docker-multistage-push-manifest-helm.yml with: - can_deploy: false - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_deploy_helm }} - versions: ${{ needs.configure.outputs.versions }} + can_deploy: ${{ needs.configure-awshelm.outputs.can_login == 'true' && needs.configure-awshelm.outputs.can_push == 'true' }} + has_refs: ${{ needs.configure-awshelm.outputs.has_refs == 'true' }} + matrix: ${{ needs.configure-awshelm.outputs.matrix_deploy }} + versions: ${{ needs.configure-awshelm.outputs.versions }} stage: awshelm secrets: dockerhub_username: "" diff --git a/.github/workflows/action_schedule.yml b/.github/workflows/action_schedule.yml index 5ab9503..74a5a5b 100644 --- a/.github/workflows/action_schedule.yml +++ b/.github/workflows/action_schedule.yml @@ -3,7 +3,7 @@ # ------------------------------------------------------------------------------------------------- # Job Name # ------------------------------------------------------------------------------------------------- -name: build +name: nightly # ------------------------------------------------------------------------------------------------- @@ -13,288 +13,230 @@ on: # Runs daily schedule: - cron: '0 0 * * *' + # Dispatch: allows for manual trigger via GH UI + workflow_dispatch: jobs: # ----------------------------------------------------------------------------------------------- - # (1/5) Determine parameter settings + # (1/4) Determine parameter settings # ----------------------------------------------------------------------------------------------- params: uses: ./.github/workflows/params.yml # ----------------------------------------------------------------------------------------------- - # (2/5) Configure Build and Deploy Matrices + # (2/4) Configure Build and Deploy Matrices # ----------------------------------------------------------------------------------------------- configure: needs: [params] - uses: ./.github/workflows/docker-multistage-configure-extra.yml + uses: ./.github/workflows/docker-multistage-configure.yml with: enabled: true can_deploy: true - is_scheduled: 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 + with: + enabled: true + can_deploy: true + versions: ${{ needs.params.outputs.versions }} + refs: ${{ needs.params.outputs.refs }} + fields_build: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"KOPS":"EXTRA"}, {"ARCH":"ARCH"}]' + fields_deploy: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"KOPS":"EXTRA"}]' + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} + + configure-awshelm: + needs: [params] + uses: ./.github/workflows/docker-multistage-configure.yml + with: + enabled: true + can_deploy: true + versions: ${{ needs.params.outputs.versions }} + refs: ${{ needs.params.outputs.refs }} + fields_build: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"HELM":"EXTRA"}, {"ARCH":"ARCH"}]' + fields_deploy: '[{"VERSION":"VERSION"}, {"FLAVOUR":"FLAVOUR"}, {"HELM":"EXTRA"}]' + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} + + # ----------------------------------------------------------------------------------------------- - # (3/5) Build & Test + # (3/4) Build & Test # ----------------------------------------------------------------------------------------------- build-base: needs: - configure - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: true + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: base stage_prev: '' + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-tools: needs: - configure - build-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: tools stage_prev: base + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-aws: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: aws stage_prev: tools + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-azure: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: azure stage_prev: tools + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-infra: needs: - configure - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: infra stage_prev: tools + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} build-awsk8s: needs: - configure - build-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-build.yml@master + uses: ./.github/workflows/docker-multistage-build.yml with: has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true - upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build }} artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} + upload_artifact: true pull_base_image: false + push_image: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure.outputs.matrix_build }} stage: awsk8s stage_prev: aws + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} # Note: awskops is special build-awskops: needs: - - configure + - configure-awskops - build-awsk8s - uses: ./.github/workflows/docker-multistage-build-kops.yml + uses: ./.github/workflows/docker-multistage-build-extra.yml with: - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true + has_refs: ${{ needs.configure-awskops.outputs.has_refs == 'true' }} + artifact_prefix: ${{ needs.configure-awskops.outputs.artifact_prefix }} upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build_kops }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} pull_base_image: false + push_image: ${{ needs.configure-awskops.outputs.can_login == 'true' && needs.configure-awskops.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure-awskops.outputs.matrix_build }} stage: awskops stage_prev: awsk8s + extra_make_var_name: KOPS + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} # Note: awshelm is special build-awshelm: needs: - - configure + - configure-awshelm - build-awsk8s - uses: ./.github/workflows/docker-multistage-build-helm.yml + uses: ./.github/workflows/docker-multistage-build-extra.yml with: - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - run_tests: true + has_refs: ${{ needs.configure-awshelm.outputs.has_refs == 'true' }} + artifact_prefix: ${{ needs.configure-awshelm.outputs.artifact_prefix }} upload_artifact: true - matrix: ${{ needs.configure.outputs.matrix_build_helm }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} pull_base_image: false + push_image: ${{ needs.configure-awshelm.outputs.can_login == 'true' && needs.configure-awshelm.outputs.can_push == 'true' }} + run_tests: true + matrix: ${{ needs.configure-awshelm.outputs.matrix_build }} stage: awshelm stage_prev: awsk8s - - # ----------------------------------------------------------------------------------------------- - # (4/5) Push images - # ----------------------------------------------------------------------------------------------- - push-base: - needs: - - configure - - build-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: base - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-tools: - needs: - - configure - - build-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: tools - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-infra: - needs: - - configure - - build-infra - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: infra - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-azure: - needs: - - configure - - build-azure - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: azure + extra_make_var_name: HELM secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - push-aws: - needs: - - configure - - build-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: aws - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - push-awsk8s: - needs: - - configure - - build-awsk8s - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-image.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' }} - matrix: ${{ needs.configure.outputs.matrix_build }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awsk8s - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - # Note: awskops is special - push-awskops: - needs: - - configure - - build-awskops - uses: ./.github/workflows/docker-multistage-push-image-kops.yml - with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build_kops }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awskops - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} - - # Note: awshelm is special - push-awshelm: - needs: - - configure - - build-awshelm - uses: ./.github/workflows/docker-multistage-push-image-helm.yml - with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_build_helm }} - artifact_prefix: ${{ needs.configure.outputs.artifact_prefix }} - stage: awshelm - secrets: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} # ----------------------------------------------------------------------------------------------- - # (5/5) Push Manifests + # (4/4) Push Manifests # ----------------------------------------------------------------------------------------------- manifest-base: needs: - configure - - push-base - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-base + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -308,8 +250,8 @@ jobs: manifest-tools: needs: - configure - - push-tools - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-tools + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -323,8 +265,8 @@ jobs: manifest-infra: needs: - configure - - push-infra - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-infra + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -338,8 +280,8 @@ jobs: manifest-azure: needs: - configure - - push-azure - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-azure + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -353,8 +295,8 @@ jobs: manifest-aws: needs: - configure - - push-aws - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-aws + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -368,8 +310,8 @@ jobs: manifest-awsk8s: needs: - configure - - push-awsk8s - uses: devilbox/github-actions/.github/workflows/docker-multistage-push-manifest.yml@master + - build-awsk8s + uses: ./.github/workflows/docker-multistage-push-manifest.yml with: can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} @@ -383,14 +325,14 @@ jobs: # Note: awskops is special manifest-awskops: needs: - - configure - - push-awskops + - configure-awskops + - build-awskops uses: ./.github/workflows/docker-multistage-push-manifest-kops.yml with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_deploy_kops }} - versions: ${{ needs.configure.outputs.versions }} + can_deploy: ${{ needs.configure-awskops.outputs.can_login == 'true' && needs.configure-awskops.outputs.can_push == 'true' }} + has_refs: ${{ needs.configure-awskops.outputs.has_refs == 'true' }} + matrix: ${{ needs.configure-awskops.outputs.matrix_deploy }} + versions: ${{ needs.configure-awskops.outputs.versions }} stage: awskops secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -399,14 +341,14 @@ jobs: # Note: awshelm is special manifest-awshelm: needs: - - configure - - push-awshelm + - configure-awshelm + - build-awshelm uses: ./.github/workflows/docker-multistage-push-manifest-helm.yml with: - can_deploy: ${{ needs.configure.outputs.can_login == 'true' && needs.configure.outputs.can_push == 'true' }} - has_refs: ${{ needs.configure.outputs.has_refs == 'true' }} - matrix: ${{ needs.configure.outputs.matrix_deploy_helm }} - versions: ${{ needs.configure.outputs.versions }} + can_deploy: ${{ needs.configure-awshelm.outputs.can_login == 'true' && needs.configure-awshelm.outputs.can_push == 'true' }} + has_refs: ${{ needs.configure-awshelm.outputs.has_refs == 'true' }} + matrix: ${{ needs.configure-awshelm.outputs.matrix_deploy }} + versions: ${{ needs.configure-awshelm.outputs.versions }} stage: awshelm secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} diff --git a/.github/workflows/docker-multistage-build-kops.yml b/.github/workflows/docker-multistage-build-extra.yml similarity index 55% rename from .github/workflows/docker-multistage-build-kops.yml rename to .github/workflows/docker-multistage-build-extra.yml index b06243b..2808f81 100644 --- a/.github/workflows/docker-multistage-build-kops.yml +++ b/.github/workflows/docker-multistage-build-extra.yml @@ -35,18 +35,37 @@ on: description: 'Dertermines whether we upload the artifact not.' required: true type: boolean - pull_base_image: - description: 'Pull Docker base image before building?.' + 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 + extra_make_var_name: + description: 'Extra makefile variable name to assign matrix.EXTRA value to' + required: true + type: string + ### + ### 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.kops }} (${{ matrix.arch }}) ${{ matrix.refs }} + name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }}${{ matrix.EXTRA }} (${{ matrix.ARCH }}) ${{ matrix.REFS }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -63,11 +82,11 @@ jobs: fetch-depth: 0 if: ${{ !inputs.has_refs }} - - name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" + - name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})" uses: actions/checkout@v3 with: fetch-depth: 0 - ref: ${{ matrix.refs }} + ref: ${{ matrix.REFS }} if: ${{ inputs.has_refs }} - name: "[SETUP] Install QEMU environment" @@ -77,40 +96,32 @@ jobs: image: tonistiigi/binfmt:latest platforms: all - - name: "[SETUP] Install Docker Buildx" - id: buildx - uses: docker/setup-buildx-action@v2 - - name: "[SETUP] Set artifact names" id: set-artifact-name run: | - PRE_HASH="$( git rev-parse HEAD | head -c 10 )" - VERSION="${{ matrix.version }}" - ARCH="$( echo "${{ matrix.arch }}" | sed 's|/|-|g' )" + VERSION="$( echo "${{ matrix.VERSION }}" )" + ARCH="$( echo "${{ matrix.ARCH }}" | sed 's|/|-|g' )" - NAME_PREV="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-${{ inputs.stage_prev }}" - NAME_CURR="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-${{ inputs.stage }}${{ matrix.kops }}" + NAME_PREV="${{ inputs.artifact_prefix }}-${VERSION}-${ARCH}-${{ inputs.stage_prev }}" + NAME_CURR="${{ inputs.artifact_prefix }}-${VERSION}-${ARCH}-${{ inputs.stage }}${{ matrix.EXTRA }}" echo "prev=${NAME_PREV}" >> $GITHUB_OUTPUT echo "curr=${NAME_CURR}" >> $GITHUB_OUTPUT - - name: "[DEBUG] Show setup" - shell: bash + - 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: | - echo '(qemu) Platforms: ${{ steps.qemu.outputs.platforms }}' - echo "(buildx) Name: ${{ steps.buildx.outputs.name }}" - echo "(buildx) Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "(buildx) Status: ${{ steps.buildx.outputs.status }}" - echo "(buildx) Flags: ${{ steps.buildx.outputs.flags }}" - echo "(buildx) Platforms: ${{ steps.buildx.outputs.platforms }}" + sysctl net.ipv4.ip_forward + sudo sysctl -w net.ipv4.ip_forward=1 + sudo systemctl restart docker # ------------------------------------------------------------ # Artifact Import # ------------------------------------------------------------ - - ### - ### Download and import previously built image (if it exists) - ### - name: "[Artifact Load] Download previously built image" uses: cytopia/download-artifact-retry-action@v0.1.4 with: @@ -132,14 +143,14 @@ jobs: 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 }} KOPS=${{ matrix.kops }} + make docker-pull-base-image VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} ${{ inputs.extra_make_var_name }}=${{ matrix.EXTRA }} 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 }} KOPS=${{ matrix.kops }} + make build VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} ${{ inputs.extra_make_var_name }}=${{ matrix.EXTRA }} # ------------------------------------------------------------ @@ -149,24 +160,44 @@ jobs: 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 }} KOPS=${{ matrix.kops }} + make test VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} ${{ inputs.extra_make_var_name }}=${{ matrix.EXTRA }} if: ${{ inputs.run_tests }} # ------------------------------------------------------------ - # Artifact Export + # 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 }} ${{ inputs.extra_make_var_name }}=${{ matrix.EXTRA }} + + - 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 }} ${{ inputs.extra_make_var_name }}=${{ matrix.EXTRA }} + if: ${{ inputs.push_image }} + - ### - ### Export current 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 }} KOPS=${{ matrix.kops }} OUTFILE=${{ steps.set-artifact-name.outputs.curr }} INFILE=${{ steps.set-artifact-name.outputs.curr }} + 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 }} ${{ inputs.extra_make_var_name }}=${{ matrix.EXTRA }} post_command: | make load INFILE={{download_path}} if: ${{ inputs.upload_artifact }} diff --git a/.github/workflows/docker-multistage-build-helm.yml b/.github/workflows/docker-multistage-build.yml similarity index 59% rename from .github/workflows/docker-multistage-build-helm.yml rename to .github/workflows/docker-multistage-build.yml index 4a64df0..976de2c 100644 --- a/.github/workflows/docker-multistage-build-helm.yml +++ b/.github/workflows/docker-multistage-build.yml @@ -1,5 +1,5 @@ --- -name: "Build multistage docker images (multi -flavours, -versions, -architectures -helm)" +name: "Build multistage docker images (multi -flavours, -versions, -architectures)" on: workflow_call: @@ -35,18 +35,33 @@ on: description: 'Dertermines whether we upload the artifact not.' required: true type: boolean - pull_base_image: - description: 'Pull Docker base image before building?.' + 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.helm }} (${{ matrix.arch }}) ${{ matrix.refs }} + name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }} (${{ matrix.ARCH }}) ${{ matrix.REFS }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -63,11 +78,11 @@ jobs: fetch-depth: 0 if: ${{ !inputs.has_refs }} - - name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" + - name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})" uses: actions/checkout@v3 with: fetch-depth: 0 - ref: ${{ matrix.refs }} + ref: ${{ matrix.REFS }} if: ${{ inputs.has_refs }} - name: "[SETUP] Install QEMU environment" @@ -77,40 +92,32 @@ jobs: image: tonistiigi/binfmt:latest platforms: all - - name: "[SETUP] Install Docker Buildx" - id: buildx - uses: docker/setup-buildx-action@v2 - - name: "[SETUP] Set artifact names" id: set-artifact-name run: | - PRE_HASH="$( git rev-parse HEAD | head -c 10 )" - VERSION="${{ matrix.version }}" - ARCH="$( echo "${{ matrix.arch }}" | sed 's|/|-|g' )" + VERSION="$( echo "${{ matrix.VERSION }}" )" + ARCH="$( echo "${{ matrix.ARCH }}" | sed 's|/|-|g' )" - NAME_PREV="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-${{ inputs.stage_prev }}" - NAME_CURR="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-${{ inputs.stage }}${{ matrix.helm }}" + 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: "[DEBUG] Show setup" - shell: bash + - 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: | - echo '(qemu) Platforms: ${{ steps.qemu.outputs.platforms }}' - echo "(buildx) Name: ${{ steps.buildx.outputs.name }}" - echo "(buildx) Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "(buildx) Status: ${{ steps.buildx.outputs.status }}" - echo "(buildx) Flags: ${{ steps.buildx.outputs.flags }}" - echo "(buildx) Platforms: ${{ steps.buildx.outputs.platforms }}" + sysctl net.ipv4.ip_forward + sudo sysctl -w net.ipv4.ip_forward=1 + sudo systemctl restart docker # ------------------------------------------------------------ # Artifact Import # ------------------------------------------------------------ - - ### - ### Download and import previously built image (if it exists) - ### - name: "[Artifact Load] Download previously built image" uses: cytopia/download-artifact-retry-action@v0.1.4 with: @@ -132,14 +139,14 @@ jobs: 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 }} HELM=${{ matrix.helm }} + 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 }} HELM=${{ matrix.helm }} + make build VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} # ------------------------------------------------------------ @@ -149,24 +156,44 @@ jobs: 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 }} HELM=${{ matrix.helm }} + make test VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCH=${{ matrix.ARCH }} if: ${{ inputs.run_tests }} # ------------------------------------------------------------ - # Artifact Export + # 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 }} - ### - ### Export current image - ### + - 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 }} HELM=${{ matrix.helm }} OUTFILE=${{ steps.set-artifact-name.outputs.curr }} INFILE=${{ steps.set-artifact-name.outputs.curr }} + 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-extra.yml b/.github/workflows/docker-multistage-configure.yml similarity index 61% rename from .github/workflows/docker-multistage-configure-extra.yml rename to .github/workflows/docker-multistage-configure.yml index d5a2734..ac9742c 100644 --- a/.github/workflows/docker-multistage-configure-extra.yml +++ b/.github/workflows/docker-multistage-configure.yml @@ -15,6 +15,14 @@ on: 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 @@ -23,10 +31,6 @@ on: description: 'Determines whether this workflow can deploy (login and push).' required: true type: boolean - is_scheduled: - description: "Usage for a scheduled job? Only then we will evaluate git refs and add them to build matrix." - required: true - type: boolean ### ### Input Secrets @@ -57,28 +61,16 @@ on: can_push: description: "(boolean) Can we push to Dockerhub?" value: ${{ jobs.configure.outputs.can_push }} + # Determined settings (values) has_refs: - description: "(boolean) Do we have refs? (used for nightly builds)" + description: "(string) 'true' or 'false' Do we have refs to build?" value: ${{ jobs.configure.outputs.has_refs }} - # Determined settings (values) matrix_build: description: "(string) The determined JSON string build matrix." value: ${{ jobs.configure.outputs.matrix_build }} - matrix_build_kops: - description: "(string) The determined JSON string build matrix." - value: ${{ jobs.configure.outputs.matrix_build_kops }} - matrix_build_helm: - description: "(string) The determined JSON string build matrix." - value: ${{ jobs.configure.outputs.matrix_build_helm }} matrix_deploy: description: "(string) The determined JSON string deploy matrix." value: ${{ jobs.configure.outputs.matrix_deploy }} - matrix_deploy_kops: - description: "(string) The determined JSON string deploy matrix." - value: ${{ jobs.configure.outputs.matrix_deploy_kops }} - matrix_deploy_helm: - description: "(string) The determined JSON string deploy matrix." - value: ${{ jobs.configure.outputs.matrix_deploy_helm }} artifact_prefix: description: "(string) The determined unique artifact prefix." value: ${{ jobs.configure.outputs.artifact_prefix }} @@ -103,15 +95,12 @@ jobs: # 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 }} - # Values artifact_prefix: ${{ steps.set-artifact-prefix.outputs.prefix }} + # Values matrix_build: ${{ steps.set-matrix.outputs.matrix_build }} - matrix_build_kops: ${{ steps.set-matrix.outputs.matrix_build_kops }} - matrix_build_helm: ${{ steps.set-matrix.outputs.matrix_build_helm }} matrix_deploy: ${{ steps.set-matrix.outputs.matrix_deploy }} - matrix_deploy_kops: ${{ steps.set-matrix.outputs.matrix_deploy_kops }} - matrix_deploy_helm: ${{ steps.set-matrix.outputs.matrix_deploy_helm }} ### ### Steps @@ -151,6 +140,10 @@ jobs: echo "can_push=false" >> $GITHUB_OUTPUT fi + # ------------------------------------------------------------ + # Set values + # ------------------------------------------------------------ + ### ### Do we have refs to build against? ### @@ -170,20 +163,18 @@ jobs: echo "BRANCHES=${BRANCHES}" echo "NUM_LATEST_TAGS=${NUM_LATEST_TAGS}" - - name: "[Set-Output] has_refs and matrix (ref-matrix) (branches and latest tags)" + ### + ### Set Refs + ### + - name: "[Set-Output] has_refs and ref-matrix" id: set-refs - uses: cytopia/git-ref-matrix-action@v0.1.12 + 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: ${{ !(inputs.is_scheduled && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')) }} - - - # ------------------------------------------------------------ - # Set values - # ------------------------------------------------------------ + disable_refs: ${{ !(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} ### ### Unique Artifact prefix @@ -192,9 +183,9 @@ jobs: id: set-artifact-prefix shell: bash run: | - PRE_DATE="$( date +"%s" )" - PRE_RAND="$( echo $RANDOM | md5sum | head -c 10 )" - echo "prefix=${PRE_DATE}-${PRE_RAND}" >> $GITHUB_OUTPUT + 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 @@ -203,82 +194,52 @@ jobs: 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 - # BUILD MATRICES - MATRIX_BUILD="$( \ - jq -M -c \ - --argjson refs '${{ steps.set-refs.outputs.matrix }}' \ - 'map({name:.NAME, version:.VERSION[], flavour:.FLAVOUR[], arch:.ARCH[], refs:$refs[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_BUILD_KOPS="$( \ - jq -M -c \ - --argjson refs '${{ steps.set-refs.outputs.matrix }}' \ - 'map({name:.NAME, version:.VERSION[], kops:.KOPS[], flavour:.FLAVOUR[], arch:.ARCH[], refs:$refs[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_BUILD_HELM="$( \ - jq -M -c \ - --argjson refs '${{ steps.set-refs.outputs.matrix }}' \ - 'map({name:.NAME, version:.VERSION[], helm:.HELM[], flavour:.FLAVOUR[], arch:.ARCH[], refs:$refs[]})' <<<'${{ inputs.versions }}' \ - )" + 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}" )" - # DEPLOY MATRICES - MATRIX_DEPLOY="$( \ - jq -M -c \ - --argjson refs '${{ steps.set-refs.outputs.matrix }}' \ - 'map({name:.NAME, version:.VERSION[], flavour:.FLAVOUR[], refs:$refs[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_DEPLOY_KOPS="$( \ - jq -M -c \ - --argjson refs '${{ steps.set-refs.outputs.matrix }}' \ - 'map({name:.NAME, version:.VERSION[], kops:.KOPS[], flavour:.FLAVOUR[], refs:$refs[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_DEPLOY_HELM="$( \ - jq -M -c \ - --argjson refs '${{ steps.set-refs.outputs.matrix }}' \ - 'map({name:.NAME, version:.VERSION[], helm:.HELM[], flavour:.FLAVOUR[], refs:$refs[]})' <<<'${{ inputs.versions }}' \ - )" echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT - echo "matrix_build_kops=${MATRIX_BUILD_KOPS}" >> $GITHUB_OUTPUT - echo "matrix_build_helm=${MATRIX_BUILD_HELM}" >> $GITHUB_OUTPUT echo "matrix_deploy=${MATRIX_DEPLOY}" >> $GITHUB_OUTPUT - echo "matrix_deploy_kops=${MATRIX_DEPLOY_KOPS}" >> $GITHUB_OUTPUT - echo "matrix_deploy_helm=${MATRIX_DEPLOY_HELM}" >> $GITHUB_OUTPUT - echo "has_refs=true" >> $GITHUB_OUTPUT + else - # BUILD MATRICES - MATRIX_BUILD="$( \ - jq -M -c \ - 'map({name:.NAME, version:.VERSION[], flavour:.FLAVOUR[], arch:.ARCH[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_BUILD_KOPS="$( \ - jq -M -c \ - 'map({name:.NAME, version:.VERSION[], kops:.KOPS[], flavour:.FLAVOUR[], arch:.ARCH[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_BUILD_HELM="$( \ - jq -M -c \ - 'map({name:.NAME, version:.VERSION[], helm:.HELM[], flavour:.FLAVOUR[], arch:.ARCH[]})' <<<'${{ inputs.versions }}' \ - )" - # DEPLOY MATRICES - MATRIX_DEPLOY="$( \ - jq -M -c \ - 'map({name:.NAME, version:.VERSION[], flavour:.FLAVOUR[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_DEPLOY_KOPS="$( \ - jq -M -c \ - 'map({name:.NAME, version:.VERSION[], kops:.KOPS[], flavour:.FLAVOUR[]})' <<<'${{ inputs.versions }}' \ - )" - MATRIX_DEPLOY_HELM="$( \ - jq -M -c \ - 'map({name:.NAME, version:.VERSION[], helm:.HELM[], flavour:.FLAVOUR[]})' <<<'${{ inputs.versions }}' \ - )" + # 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_build_kops=${MATRIX_BUILD_KOPS}" >> $GITHUB_OUTPUT - echo "matrix_build_helm=${MATRIX_BUILD_HELM}" >> $GITHUB_OUTPUT echo "matrix_deploy=${MATRIX_DEPLOY}" >> $GITHUB_OUTPUT - echo "matrix_deploy_kops=${MATRIX_DEPLOY_KOPS}" >> $GITHUB_OUTPUT - echo "matrix_deploy_helm=${MATRIX_DEPLOY_HELM}" >> $GITHUB_OUTPUT - echo "has_refs=false" >> $GITHUB_OUTPUT fi # ------------------------------------------------------------ @@ -298,6 +259,8 @@ jobs: 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 }}' @@ -307,14 +270,20 @@ jobs: 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 'is_scheduled: ${{ inputs.is_scheduled }}' - echo 'can_deploy: ${{ inputs.can_deploy }}' echo 'versions: ${{ inputs.versions }}' echo 'refs: ${{ inputs.refs }}' @@ -327,12 +296,9 @@ jobs: # 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_build_kops: ${{ steps.set-matrix.outputs.matrix_build_kops }}' - echo 'matrix_build_helm: ${{ steps.set-matrix.outputs.matrix_build_helm }}' echo 'matrix_deploy: ${{ steps.set-matrix.outputs.matrix_deploy }}' - echo 'matrix_deploy_kops: ${{ steps.set-matrix.outputs.matrix_deploy_kops }}' - echo 'matrix_deploy_helm: ${{ steps.set-matrix.outputs.matrix_deploy_helm }}' diff --git a/.github/workflows/docker-multistage-push-image-helm.yml b/.github/workflows/docker-multistage-push-image-helm.yml deleted file mode 100644 index 53174b9..0000000 --- a/.github/workflows/docker-multistage-push-image-helm.yml +++ /dev/null @@ -1,145 +0,0 @@ ---- -name: "Push multistage docker images (multi -flavours, -versions, -architectures -helm)" - -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 - artifact_prefix: - description: 'Unique artifact name prefix (to avoid overriding existing artifcats during parallel runs).' - 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: true - dockerhub_password: - description: 'The password for Dockerhub.' - required: true - -jobs: - # ----------------------------------------------------------------------------------------------- - # JOB: DEPLOY - # ----------------------------------------------------------------------------------------------- - deploy: - name: ${{ matrix.name }}-${{ matrix.version }}-${{ inputs.stage }}${{ matrix.helm }} (${{ 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] 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] Set artifact names" - id: set-artifact-name - run: | - PRE_HASH="$( git rev-parse HEAD | head -c 10 )" - VERSION="${{ matrix.version }}" - ARCH="$( echo "${{ matrix.arch }}" | sed 's|/|-|g' )" - - NAME_CURR="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-${{ inputs.stage }}${{ matrix.helm }}" - - echo "curr=${NAME_CURR}" >> $GITHUB_OUTPUT - - - # ------------------------------------------------------------ - # Artifact Import - # ------------------------------------------------------------ - - ### - ### Download and import previously built image - ### - - name: "[Artifact Load] Download previously built image" - uses: cytopia/download-artifact-retry-action@v0.1.4 - with: - name: ${{ steps.set-artifact-name.outputs.curr }} - - - 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.curr }} - - - # ------------------------------------------------------------ - # Re-tag images - # ------------------------------------------------------------ - - name: "[Docker Tag] Retag" - 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 }} HELM=${{ matrix.helm }} - - - name: "[Docker Tag] Show images" - run: | - docker images - - - # ------------------------------------------------------------ - # Login - # ------------------------------------------------------------ - - name: Login - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - if: ${{ inputs.can_deploy }} - - - # ------------------------------------------------------------ - # Push images - # ------------------------------------------------------------ - - name: Push Image - 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 }} HELM=${{ matrix.helm }} - if: ${{ inputs.can_deploy }} diff --git a/.github/workflows/docker-multistage-push-manifest-helm.yml b/.github/workflows/docker-multistage-push-manifest-helm.yml index b9562e3..9551c96 100644 --- a/.github/workflows/docker-multistage-push-manifest-helm.yml +++ b/.github/workflows/docker-multistage-push-manifest-helm.yml @@ -28,6 +28,7 @@ on: required: true type: boolean + ### ### Secrets ### @@ -44,7 +45,7 @@ jobs: # JOB (3/3): DEPLOY # ----------------------------------------------------------------------------------------------- deploy: - name: ${{ matrix.name }}-${{ matrix.version }}-${{ inputs.stage }}${{ matrix.helm }} ${{ matrix.refs }} + name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }}${{ matrix.EXTRA }} ${{ matrix.REFS }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -61,11 +62,11 @@ jobs: fetch-depth: 0 if: ${{ !inputs.has_refs }} - - name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" + - name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})" uses: actions/checkout@v3 with: fetch-depth: 0 - ref: ${{ matrix.refs }} + ref: ${{ matrix.REFS }} if: ${{ inputs.has_refs }} - name: "[SETUP] Setup QEMU environment" @@ -82,9 +83,9 @@ jobs: id: manifest run: | ARCHES="$( echo '${{ inputs.versions }}' \ - | jq 'group_by(.NAME, .VERSION, .HELM, .ARCH)' \ - | jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], HELM: .[].HELM[], FLAVOUR: .[].FLAVOUR[], ARCHES: .[].ARCH|join(",")})' \ - | jq '.[] | select(.NAME=="${{ matrix.name }}" and .VERSION=="${{ matrix.version }}" and .HELM=="${{ matrix.helm }}" and .FLAVOUR=="${{ matrix.flavour }}") | .ARCHES' \ + | jq 'group_by(.NAME, .VERSION, .FLAVOUR, .HELM, .ARCH)' \ + | jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], FLAVOUR: .[].FLAVOUR[], HELM: .[].HELM[], ARCHES: .[].ARCH|join(",")})' \ + | jq '.[] | select(.NAME=="${{ matrix.NAME }}" and .VERSION=="${{ matrix.VERSION }}" and .FLAVOUR=="${{ matrix.FLAVOUR }}" and .HELM=="${{ matrix.EXTRA }}") | .ARCHES' \ | jq -c -M \ )" echo "arches=${ARCHES}" >> $GITHUB_OUTPUT @@ -108,7 +109,7 @@ jobs: 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 }} HELM=${{ matrix.helm }} + make manifest-create VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCHES=${{ steps.manifest.outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }} HELM=${{ matrix.EXTRA }} # ------------------------------------------------------------ @@ -118,4 +119,4 @@ jobs: 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 }} HELM=${{ matrix.helm }} + make manifest-push VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} TAG=${{ steps.tag.outputs.docker-tag }} HELM=${{ matrix.EXTRA }} diff --git a/.github/workflows/docker-multistage-push-manifest-kops.yml b/.github/workflows/docker-multistage-push-manifest-kops.yml index 7067eaa..dc31604 100644 --- a/.github/workflows/docker-multistage-push-manifest-kops.yml +++ b/.github/workflows/docker-multistage-push-manifest-kops.yml @@ -28,6 +28,7 @@ on: required: true type: boolean + ### ### Secrets ### @@ -44,7 +45,7 @@ jobs: # JOB (3/3): DEPLOY # ----------------------------------------------------------------------------------------------- deploy: - name: ${{ matrix.name }}-${{ matrix.version }}-${{ inputs.stage }}${{ matrix.kops }} ${{ matrix.refs }} + name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }}${{ matrix.EXTRA }} ${{ matrix.REFS }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -61,11 +62,11 @@ jobs: fetch-depth: 0 if: ${{ !inputs.has_refs }} - - name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" + - name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})" uses: actions/checkout@v3 with: fetch-depth: 0 - ref: ${{ matrix.refs }} + ref: ${{ matrix.REFS }} if: ${{ inputs.has_refs }} - name: "[SETUP] Setup QEMU environment" @@ -82,9 +83,9 @@ jobs: id: manifest run: | ARCHES="$( echo '${{ inputs.versions }}' \ - | jq 'group_by(.NAME, .VERSION, .KOPS, .ARCH)' \ - | jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], KOPS: .[].KOPS[], FLAVOUR: .[].FLAVOUR[], ARCHES: .[].ARCH|join(",")})' \ - | jq '.[] | select(.NAME=="${{ matrix.name }}" and .VERSION=="${{ matrix.version }}" and .KOPS=="${{ matrix.kops }}" and .FLAVOUR=="${{ matrix.flavour }}") | .ARCHES' \ + | jq 'group_by(.NAME, .VERSION, .FLAVOUR, .KOPS, .ARCH)' \ + | jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], FLAVOUR: .[].FLAVOUR[], KOPS: .[].KOPS[], ARCHES: .[].ARCH|join(",")})' \ + | jq '.[] | select(.NAME=="${{ matrix.NAME }}" and .VERSION=="${{ matrix.VERSION }}" and .FLAVOUR=="${{ matrix.FLAVOUR }}" and .KOPS=="${{ matrix.EXTRA }}") | .ARCHES' \ | jq -c -M \ )" echo "arches=${ARCHES}" >> $GITHUB_OUTPUT @@ -108,7 +109,7 @@ jobs: 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 }} KOPS=${{ matrix.kops }} + make manifest-create VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCHES=${{ steps.manifest.outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }} KOPS=${{ matrix.EXTRA }} # ------------------------------------------------------------ @@ -118,4 +119,4 @@ jobs: 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 }} KOPS=${{ matrix.kops }} + make manifest-push VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} TAG=${{ steps.tag.outputs.docker-tag }} KOPS=${{ matrix.EXTRA }} diff --git a/.github/workflows/docker-multistage-push-image-kops.yml b/.github/workflows/docker-multistage-push-manifest.yml similarity index 54% rename from .github/workflows/docker-multistage-push-image-kops.yml rename to .github/workflows/docker-multistage-push-manifest.yml index 7841d9a..b9c7271 100644 --- a/.github/workflows/docker-multistage-push-image-kops.yml +++ b/.github/workflows/docker-multistage-push-manifest.yml @@ -1,5 +1,5 @@ --- -name: "Push multistage docker images (multi -flavours, -versions, -architectures -kops)" +name: Deploy multi-arch image manifests on: workflow_call: @@ -8,15 +8,15 @@ on: ### inputs: matrix: - description: 'The build matrix' + description: 'The version deploy matrix as JSON string ( list of objects: [{NAME, VERSION[], ARCH[]}] ).' required: true type: string - stage: - description: 'The stage to build (Examples: base, mods, prod or work).' + versions: + description: 'The build matrix set via params.yml.' required: true type: string - artifact_prefix: - description: 'Unique artifact name prefix (to avoid overriding existing artifcats during parallel runs).' + stage: + description: 'The stage to build (Examples: base, mods, prod or work).' required: true type: string can_deploy: @@ -28,30 +28,31 @@ on: required: true type: boolean + ### ### Secrets ### secrets: dockerhub_username: description: 'The username for Dockerhub.' - required: true + required: false dockerhub_password: description: 'The password for Dockerhub.' - required: true + required: false jobs: # ----------------------------------------------------------------------------------------------- - # JOB: DEPLOY + # JOB (3/3): DEPLOY # ----------------------------------------------------------------------------------------------- deploy: - name: ${{ matrix.name }}-${{ matrix.version }}-${{ inputs.stage }}${{ matrix.kops }} (${{ matrix.arch }}) ${{ matrix.refs }} + 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 # ------------------------------------------------------------ @@ -61,11 +62,11 @@ jobs: fetch-depth: 0 if: ${{ !inputs.has_refs }} - - name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" + - name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})" uses: actions/checkout@v3 with: fetch-depth: 0 - ref: ${{ matrix.refs }} + ref: ${{ matrix.REFS }} if: ${{ inputs.has_refs }} - name: "[SETUP] Setup QEMU environment" @@ -78,68 +79,44 @@ jobs: id: tag uses: cytopia/docker-tag-action@v0.4.22 - - name: "[SETUP] Set artifact names" - id: set-artifact-name + - name: "[SETUP] Determine manifest arches" + id: manifest run: | - PRE_HASH="$( git rev-parse HEAD | head -c 10 )" - VERSION="${{ matrix.version }}" - ARCH="$( echo "${{ matrix.arch }}" | sed 's|/|-|g' )" - - NAME_CURR="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-${{ inputs.stage }}${{ matrix.kops }}" - - echo "curr=${NAME_CURR}" >> $GITHUB_OUTPUT + 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}" # ------------------------------------------------------------ - # Artifact Import + # Login # ------------------------------------------------------------ - - ### - ### Download and import previously built image - ### - - name: "[Artifact Load] Download previously built image" - uses: cytopia/download-artifact-retry-action@v0.1.4 - with: - name: ${{ steps.set-artifact-name.outputs.curr }} - - - name: "[Artifact Load] Import previously built image" - uses: cytopia/shell-command-retry-action@v0.1.5 + - name: "Login" + uses: docker/login-action@v2 with: - command: | - make load INFILE=${{ steps.set-artifact-name.outputs.curr }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} # ------------------------------------------------------------ - # Re-tag images + # Create Manifest # ------------------------------------------------------------ - - name: "[Docker Tag] Retag" + - name: "[Create Manifest] (${{ steps.manifest.outputs.arches }})" 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 }} KOPS=${{ matrix.kops }} - - - name: "[Docker Tag] Show images" - run: | - docker images - - - # ------------------------------------------------------------ - # Login - # ------------------------------------------------------------ - - name: Login - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - if: ${{ inputs.can_deploy }} + make manifest-create VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCHES=${{ steps.manifest.outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }} # ------------------------------------------------------------ - # Push images + # Deploy Manifest # ------------------------------------------------------------ - - name: Push Image + - name: "[Push Manifest] ${{ steps.tag.outputs.docker-tag }}" 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 }} KOPS=${{ matrix.kops }} - if: ${{ inputs.can_deploy }} + 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 a58f2fa..297ae69 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -50,6 +50,16 @@ 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: >- + { + "DEFAULT_BRANCH": "master", + "BRANCHES": "master", + "NUM_LATEST_TAGS": 0 + } # ------------------------------------------------------------------------------------------------- @@ -59,45 +69,60 @@ on: workflow_call: outputs: versions: - description: "The determined Ansible version matrix" + description: "Stringified JSON of Versions definition." value: ${{ jobs.params.outputs.versions }} refs: - description: "The determined git ref matrix (only during scheduled run)" + 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: runs-on: ubuntu-latest outputs: - versions: ${{ steps.set-matrix.outputs.versions }} - refs: ${{ steps.set-refs.outputs.matrix }} + 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] Matrix" - id: set-matrix + - name: "[Set-Output] JSON" + id: set-json run: | - VERSIONS="$( echo '${{ env.VERSIONS }}' | jq -M -c )" - echo "versions=${VERSIONS}" >> $GITHUB_OUTPUT + 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 )" - - name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)" - id: set-refs - uses: cytopia/git-ref-matrix-action@v0.1.12 - with: - repository_default_branch: master - branches: master - num_latest_tags: 0 - if: github.event_name == 'schedule' + 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: | echo 'Versions' echo '--------------------' - echo '${{ steps.set-matrix.outputs.versions }}' + echo '${{ steps.set-json.outputs.versions }}' echo echo 'Refs' echo '--------------------' - echo '${{ steps.set-refs.outputs.matrix }}' + 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