Publish Docker Images #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Docker Images | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Image version (For example: 1.0.0)" | |
| required: true | |
| build-latest: | |
| description: "Build and publish latest image" | |
| type: boolean | |
| default: false | |
| required: false | |
| env: | |
| VERSION_TAG: ${{ github.event.inputs.version }} | |
| REGISTRY_IMAGE: featbit/featbit-agent | |
| jobs: | |
| build: | |
| name: Build and publish image to Docker Hub | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| tags: | | |
| type=raw,value=${{ env.VERSION_TAG }} | |
| type=raw,value=latest,enable=${{ github.event.inputs.build-latest }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |