commit a6282d1147c8edba8599bfe8fe7ffafbd732deff Author: ytshih Date: Wed Apr 23 08:51:39 2025 +0800 Initial commit diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..04211c2 --- /dev/null +++ b/action.yaml @@ -0,0 +1,81 @@ +--- +name: "Docker builder" +description: "Build and push container images using docker" +author: Yi-Ting Shih + +inputs: + context: + description: "The context of the build environment" + required: false + default: . + file: + description: "The file location of Dockerfile" + required: false + default: ./Dockerfile + push: + description: "Whether the container will be pushed or not" + required: false + default: true + push-registry: + description: "The registry to push to" + required: false + default: gitea.konchin.com + cache: + description: "Whether the container will be cached or not" + required: false + default: true + registry-certificate: + description: "The certificate for registry" + required: false + username: + description: "The username of the user to use when push" + required: false + password: + description: "The password of the user to use when push" + required: false + +runs: + using: composite + steps: + - name: Checkout repository + uses: actions/checkout@v4.2.2 +# - name: Setup docker qemu +# uses: docker/setup-qemu-action@v3.6.0 + - name: Setup Root CA + run: | + echo "${{ inputs.registry-certificate }}" | tee ca.pem + - name: Setup Docker BuildX + uses: docker/setup-buildx-action@v3.10.0 + with: + config-inline: | + [registry."${{ inputs.push-registry }}"] + ca = ["ca.pem"] + - name: Login to registry + uses: docker/login-action@v3.4.0 + with: + registry: ${{ inputs.push-registry }} + username: ${{ inputs.username }} + password: ${{ inputs.password }} + - name: Setup metadata + id: meta + uses: docker/metadata-action@5.7.0 + with: + images: | + ${{ inputs.push-registry }}/${{ env.GITEA_REPO }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + - name: Build and push with docker + uses: docker/build-push-action@v6.15.0 + with: + context: ${{ inputs.context }} + file: ${{ inputs.file }} + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: | + type:registry,ref=${{ inputs.push-registry }}/${{ env.GITEA_REPO }}/cache + cache-to: | + type:registry,ref=${{ inputs.push-registry }}/${{ env.GITEA_REPO }}/cache