Build & Push #92
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: Build and Push Docker Image | |
| run-name: Build & Push | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| sourcetag: | |
| description: 'Tag for the Docker image' | |
| required: true | |
| default: 'latest' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set image prefix | |
| id: set_image_prefix | |
| run: | | |
| echo "IMAGE_URL_PREFIX=away168/deployment-agent:${{ github.event.inputs.sourcetag }}" >> $GITHUB_ENV | |
| - name: Print Inputs to Summary | |
| run: | | |
| echo '### Workflow Inputs' >> $GITHUB_STEP_SUMMARY | |
| echo '| Input | Value |' >> $GITHUB_STEP_SUMMARY | |
| echo '|---|---|' >> $GITHUB_STEP_SUMMARY | |
| echo '| **sourcetag** | `${{ github.event.inputs.sourcetag }}` |' >> $GITHUB_STEP_SUMMARY | |
| echo '| **image url prefix** | `${{ env.IMAGE_URL_PREFIX }}` |' >> $GITHUB_STEP_SUMMARY | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: away168 | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push for user 1003050001 | |
| id: docker_build_1003050001 | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: env0/custom-image/spectral-image | |
| build-args: | | |
| BASE_TAG=${{ github.event.inputs.sourcetag }} | |
| USER_ID=1003050001 | |
| push: true | |
| tags: ${{ env.IMAGE_URL_PREFIX }}-1003050001 | |
| cache-to: type=inline | |
| - name: Build and push for user 1001000001 | |
| id: docker_build_1001000001 | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: env0/custom-image/spectral-image | |
| build-args: | | |
| BASE_TAG=${{ github.event.inputs.sourcetag }} | |
| USER_ID=1001000001 | |
| push: true | |
| tags: ${{ env.IMAGE_URL_PREFIX }}-1001000001 | |
| cache-to: type=inline | |
| - name: Build and push for user 1001210001 | |
| id: docker_build_1001210001 | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: env0/custom-image/spectral-image | |
| build-args: | | |
| BASE_TAG=${{ github.event.inputs.sourcetag }} | |
| USER_ID=1001210001 | |
| push: true | |
| tags: ${{ env.IMAGE_URL_PREFIX }}-1001210001 | |
| cache-to: type=inline | |
| - name: Log out from Docker Hub | |
| run: docker logout |