diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index f3d7fb46..cbe2195e 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -17,57 +17,69 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-image: + generate: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - + outputs: + CALVER: ${{ steps.calculate-calver.outputs.calver }} + REGISTRY: ${{ env.REGISTRY }} steps: - name: Checkout repository uses: actions/checkout@v3 + + - name: Compute outputs + run: | + echo "REGISTRY=${{ env.REGISTRY }}" >> $GITHUB_OUTPUT - - name: Generate CalVer Tag - id: calver - run: echo "::set-output name=version::v$(date +'%y.%m.%d')" - - - - name: Build gatekeeper image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - context: . - file: Dockerfile.gatekeeper - push: false - tags: | - ${{ env.REGISTRY }}/keychainmdip/gatekeeper:${{ steps.calver.outputs.version }} - labels: ${{ steps.meta.outputs.labels }} + - name: Calculate Calver + id: calculate-calver + run: | + calver=$(date +'%Y.%m.%d') + echo "calver=$calver" >> $GITHUB_ENV + echo "::set-output name=calver::$calver" + + build_test_images: + runs-on: ubuntu-latest + needs: generate + strategy: + fail-fast: false + matrix: + include: + - dockerfile: Dockerfile.gatekeeper + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/gatekeeper:${{ needs.generate.outputs.CALVER }} + - dockerfile: Dockerfile.keymaster + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/keymaster:${{ needs.generate.outputs.CALVER }} + - dockerfile: Dockerfile.hyperswarm + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ needs.generate.outputs.CALVER }} + - dockerfile: Dockerfile.tess + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/tess-mediator:${{ needs.generate.outputs.CALVER }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 - - name: Build keymaster image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: - context: . - file: Dockerfile.keymaster - push: false - tags: | - ${{ env.REGISTRY }}/keychainmdip/keymaster:${{ steps.calver.outputs.version }} - labels: ${{ steps.meta.outputs.labels }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Build hyperswarm mediator image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - context: . - file: Dockerfile.hyperswarm - push: false + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - ${{ env.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ steps.calver.outputs.version }} - labels: ${{ steps.meta.outputs.labels }} + ${{ needs.generate.outputs.CALVER }} + release - - name: Build TESS mediator image + - name: Build Docker images uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . - file: Dockerfile.tess + file: ${{ matrix.dockerfile }} push: false - tags: | - ${{ env.REGISTRY }}/keychainmdip/tess-mediator:${{ steps.calver.outputs.version }} - labels: ${{ steps.meta.outputs.labels }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 976f6e01..6ee15571 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,7 +7,7 @@ # To get a newer version, you will need to update the SHA. # You can also reference a tag or branch, but the action may change without warning. -name: Build and publish Docker images +name: Build & Publish on: push: @@ -18,20 +18,57 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-and-push-image: + generate: runs-on: ubuntu-latest + outputs: + CALVER: ${{ steps.calculate-calver.outputs.calver }} + REGISTRY: ${{ env.REGISTRY }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Compute outputs + run: | + echo "REGISTRY=${{ env.REGISTRY }}" >> $GITHUB_OUTPUT + + - name: Calculate Calver + id: calculate-calver + run: | + calver=$(date +'%Y.%m.%d') + echo "calver=$calver" >> $GITHUB_ENV + echo "::set-output name=calver::$calver" + + build_test_images: + runs-on: ubuntu-latest + needs: generate + strategy: + fail-fast: false + matrix: + include: + - dockerfile: Dockerfile.gatekeeper + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/gatekeeper:${{ needs.generate.outputs.CALVER }} + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/gatekeeper:release + - dockerfile: Dockerfile.keymaster + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/keymaster:${{ needs.generate.outputs.CALVER }} + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/keymaster:release + - dockerfile: Dockerfile.hyperswarm + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ needs.generate.outputs.CALVER }} + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/hyperswarm-mediator:release + - dockerfile: Dockerfile.tess + tags: | + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/tess-mediator:${{ needs.generate.outputs.CALVER }} + ${{ needs.generate.outputs.REGISTRY }}/keychainmdip/tess-mediator:release permissions: contents: read packages: write - + steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Generate CalVer Tag - id: calver - run: echo "::set-output name=version::v$(date +'%y.%m.%d')" - - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: @@ -45,49 +82,13 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - ${{ steps.calver.outputs.version }} + ${{ needs.generate.outputs.CALVER }} release - - name: Build and push gatekeeper image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - context: . - file: Dockerfile.gatekeeper - push: true - tags: | - ${{ env.REGISTRY }}/keychainmdip/gatekeeper:${{ steps.calver.outputs.version }} - ${{ env.REGISTRY }}/keychainmdip/gatekeeper:release - labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push keymaster image + - name: Build and push Docker images uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . - file: Dockerfile.keymaster + file: ${{ matrix.dockerfile }} push: true - tags: | - ${{ env.REGISTRY }}/keychainmdip/keymaster:${{ steps.calver.outputs.version }} - ${{ env.REGISTRY }}/keychainmdip/keymaster:release - labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push hyperswarm mediator image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - context: . - file: Dockerfile.hyperswarm - push: true - tags: | - ${{ env.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ steps.calver.outputs.version }} - ${{ env.REGISTRY }}/keychainmdip/hyperswarm-mediator:release - labels: ${{ steps.meta.outputs.labels }} - - - name: Build and push TESS mediator image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - context: . - file: Dockerfile.tess - push: true - tags: | - ${{ env.REGISTRY }}/keychainmdip/tess-mediator:${{ steps.calver.outputs.version }} - ${{ env.REGISTRY }}/keychainmdip/tess-mediator:release labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file