diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 5af86d8..f8ea5dc 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -2,49 +2,30 @@ name: Build and push Docker image on: - workflow_dispatch: - inputs: - platforms: - description: platforms to build for - type: string - default: linux/amd64,linux/arm64/v8 - required: false - image-name: - description: a base name for image tags - type: string - default: lightningstream - required: false - image-tags: - description: image tags - type: string - default: type=semver,pattern={{version}} - required: false - push: - description: push image to Docker Hub - type: boolean - required: true - secrets: - DOCKERHUB_ORGANIZATION_NAME: - required: true - DOCKERHUB_USERNAME: - required: true - DOCKERHUB_TOKEN: - required: true + push: + branches: + - main + tags: + - v[0-9]+.[0-9]+.[0-9]+ permissions: contents: read # principle of least privilege jobs: build: - name: Build Docker image + name: Build and push Docker image runs-on: ubuntu-22.04 + env: + PLATFORMS: linux/amd64,linux/arm64/v8 + IMAGE_NAME: lightningstream + IMAGE_TAGS: type=semver,pattern={{version}} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx for multi-platform builds uses: docker/setup-buildx-action@v3 with: - platforms: ${{ inputs.platforms }} + platforms: ${{ env.PLATFORMS }} - name: Log in to Docker Hub uses: docker/login-action@v3 with: @@ -54,12 +35,12 @@ jobs: uses: docker/metadata-action@v5 with: images: >- - ${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}/${{ inputs.image-name }} - tags: ${{ inputs.image-tags }} + ${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}/${{ env.IMAGE_NAME }} + tags: ${{ env.IMAGE_TAGS }} - name: Build and push Docker image uses: docker/build-push-action@v6 with: - platforms: ${{ inputs.platforms }} - push: ${{ inputs.push }} + platforms: ${{ env.PLATFORMS }} + push: true sbom: true tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }}