name: Docker build on: workflow_call: inputs: projects: required: true type: string jobs: master: strategy: fail-fast: false matrix: app: ${{ fromJSON(inputs.projects) }} name: ${{ matrix.app }} runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v3 - name: Set up QEMU id: quemu uses: docker/setup-qemu-action@v2 - name: Available platforms run: echo ${{ steps.qemu.outputs.platforms }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 # https://docs.github.com/en/actions/learn-github-actions/contexts # https://github.com/actions/checkout#Checkout-pull-request-HEAD-commit-instead-of-merge-commit - name: Determine Docker Image tag id: tags run: | npmVersion=$(cat .nvmrc | head -n 1) versionTag=${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.event.pull_request.head.sha }} echo ::set-output name=npmVersion::${npmVersion} echo ::set-output name=version::${versionTag} - name: Print config run: | git rev-parse --verify HEAD git status echo "steps.tags.outputs.version=${{ steps.tags.outputs.version }}" - name: Build and export to local Docker uses: docker/build-push-action@v3 with: load: true build-args: | APP=${{ matrix.app }} NODE_VERSION=${{ steps.tags.outputs.npmVersion }} tags: | ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local - name: Sanity check docker image run: | echo "Check .env file" docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local cat .env echo "Check ipfs-hash" docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local cat ipfs-hash echo "List html directory" docker run --rm ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:local ls -lah - name: Log in to the Container registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push id: docker_build uses: docker/build-push-action@v3 with: push: true build-args: | APP=${{ matrix.app }} NODE_VERSION=${{ steps.tags.outputs.npmVersion }} tags: | ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:latest ghcr.io/vegaprotocol/frontend/${{ matrix.app }}:${{ steps.tags.outputs.version }} - name: Add preview label uses: actions-ecosystem/action-add-labels@v1 if: ${{ github.event_name == 'pull_request' }} with: labels: ${{ matrix.app }}-preview number: ${{ github.event.number }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}