build: test iteration #7
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 SYNC | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| env: | |
| DOCKER_HUB_IMAGE_NAME: "amd64-arm64" | |
| jobs: | |
| build_push_api: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| #Allow multiplateform to be able to deply on rasp | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| #Compute tags | |
| - name: Compute Docker tags | |
| id: compute-tags | |
| run: | | |
| PACKAGE_VERSION=$(cat package.json | jq -r '.version') | |
| DOCKER_HUB_TAG_BASE=sync/${DOCKER_HUB_IMAGE_NAME}:${{github.ref_name}} | |
| DOCKER_HUB_TAG_LATEST=${DOCKER_HUB_TAG_BASE}-latest | |
| # Conditional version tag (only for prod) | |
| if [ "${{github.ref_name}}" = "prod" ]; then | |
| DOCKER_HUB_TAG_VERSION=${DOCKER_HUB_TAG_BASE}-${PACKAGE_VERSION} | |
| else | |
| DOCKER_HUB_TAG_VERSION="" | |
| fi | |
| echo "tag_latest=${DOCKER_HUB_TAG_LATEST}" >> $GITHUB_OUTPUT | |
| echo "tag_version=${DOCKER_HUB_TAG_VERSION}" >> $GITHUB_OUTPUT | |
| #Debug tags | |
| - name: Debug tags | |
| run: | | |
| echo "Latest: ${{ steps.compute-tags.outputs.tag_latest }}" | |
| echo "Version: ${{ steps.compute-tags.outputs.tag_version }}" | |
| #Build and push docker image | |
| - name: Build and push image amd64 & arm64 | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: false | |
| tags: | | |
| ${{ steps.compute-tags.outputs.tag_latest }} | |
| ${{ steps.compute-tags.outputs.tag_version }} |