diff --git a/.github/workflows/build-push-controller.yml b/.github/workflows/build-push-controller.yml new file mode 100644 index 000000000..957850eae --- /dev/null +++ b/.github/workflows/build-push-controller.yml @@ -0,0 +1,66 @@ +name: Build and Push Controller Image + +permissions: + contents: read + +on: + workflow_dispatch: + inputs: + tag: + description: "Image tag override (defaults to git SHA)" + required: false + type: string + push: + branches: [main] + paths: + - "Dockerfile" + - "cmd/**" + - "controllers/**" + - "internal/**" + - "api/**" + - "extensions/**" + - "go.mod" + - "go.sum" + - ".github/workflows/build-push-controller.yml" + +jobs: + build-and-push: + name: Build and Push Controller + runs-on: arc-runner-scale-set-dev0 + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + with: + registries: ${{ secrets.TOOLS_AWS_ACCOUNT_ID }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + image=public.ecr.aws/vend/moby/buildkit:buildx-stable-1 + + - name: Determine image tag + id: tag + run: | + if [ -n "${{ inputs.tag }}" ]; then + echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" + else + echo "tag=${{ github.sha }}" >> "$GITHUB_OUTPUT" + fi + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: | + ${{ steps.login-ecr.outputs.registry }}/agent-sandbox-controller-fork:${{ steps.tag.outputs.tag }} + cache-from: type=gha + cache-to: type=gha,mode=max