name: Push image (REUSABLE) on: workflow_call: inputs: IMAGE: required: true type: string TAGS: required: true type: string CACHE_FROM: required: true type: string DOCKERFILE: required: true type: string secrets: DOCKER_USERNAME: required: true DOCKER_TOKEN: required: true ARM_SSH_KEY: required: true ARM_SSH_CONFIG: required: true ARM_SSH_IP: required: true jobs: push: runs-on: ubuntu-latest steps: # Prepare - name: Check out repository code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Login to Docker Hub uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Login to ghcr uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Setup SSH for ARM node run: | mkdir -p ~/.ssh echo "$SSH_KEY" > ~/.ssh/id_rsa_arm chmod 600 ~/.ssh/id_rsa_arm echo "$SSH_CONFIG" | sed "s/SSH_IP/$SSH_IP/g" > ~/.ssh/config echo "ServerAliveInterval 60" >> ~/.ssh/config echo "ServerAliveCountMax 10" >> ~/.ssh/config env: SSH_KEY: ${{ secrets.ARM_SSH_KEY }} SSH_IP: ${{ secrets.ARM_SSH_IP }} SSH_CONFIG: ${{ secrets.ARM_SSH_CONFIG }} - name: Setup Buildx (ARM) uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 with: endpoint: ssh://root@arm platforms: linux/arm64,linux/arm/v7,linux/arm/v6 # Compute metadata - name: Extract metadata id: meta uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1 with: images: bunkerity/${{ inputs.IMAGE }} # Build and push - name: Build and push uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0 with: context: . file: ${{ inputs.DOCKERFILE }} platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7 push: true tags: ${{ inputs.TAGS }} labels: ${{ steps.meta.outputs.labels }} cache-from: | type=gha,scope=${{ inputs.CACHE_FROM }}-amd64 type=gha,scope=${{ inputs.CACHE_FROM }}-386 type=gha,scope=${{ inputs.CACHE_FROM }}-arm