|
| 1 | +name: Build SYNC |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + |
| 9 | +env: |
| 10 | + DOCKER_HUB_IMAGE_NAME: "amd64-arm64" |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_push_api: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v3 |
| 18 | + |
| 19 | + # #Allow multiplateform to be able to deply on rasp |
| 20 | + # - name: Set up Docker Buildx |
| 21 | + # uses: docker/setup-buildx-action@v3 |
| 22 | + |
| 23 | + #Compute tags |
| 24 | + - name: Compute Docker tags |
| 25 | + id: compute-tags |
| 26 | + run: | |
| 27 | + PACKAGE_VERSION=$(cat package.json | jq -r '.version') |
| 28 | + DOCKER_HUB_TAG_BASE=sync/${DOCKER_HUB_IMAGE_NAME}:${{github.ref_name}} |
| 29 | + DOCKER_HUB_TAG_LATEST=${DOCKER_HUB_TAG_BASE}-latest |
| 30 | + # Conditional version tag (only for prod) |
| 31 | + if [ "${{github.ref_name}}" = "prod" ]; then |
| 32 | + DOCKER_HUB_TAG_VERSION=${DOCKER_HUB_TAG_BASE}-${PACKAGE_VERSION} |
| 33 | + else |
| 34 | + DOCKER_HUB_TAG_VERSION="" |
| 35 | + fi |
| 36 | + echo "tag_latest=${DOCKER_HUB_TAG_LATEST}" >> $GITHUB_OUTPUT |
| 37 | + echo "tag_version=${DOCKER_HUB_TAG_VERSION}" >> $GITHUB_OUTPUT |
| 38 | +
|
| 39 | + #Debug tags |
| 40 | + - name: Debug tags |
| 41 | + run: | |
| 42 | + echo "Latest: ${{ steps.compute-tags.outputs.tag_latest }}" |
| 43 | + echo "Version: ${{ steps.compute-tags.outputs.tag_version }}" |
| 44 | +
|
| 45 | + #Build and push docker image |
| 46 | + - name: Build and push image amd64 |
| 47 | + uses: docker/build-push-action@v5 |
| 48 | + with: |
| 49 | + context: . |
| 50 | + file: Dockerfile |
| 51 | + platforms: linux/amd64 |
| 52 | + push: false |
| 53 | + tags: | |
| 54 | + ${{ steps.compute-tags.outputs.tag_latest }} |
| 55 | + ${{ steps.compute-tags.outputs.tag_version }} |
| 56 | +
|
| 57 | + #Build and push docker image |
| 58 | + - name: Build and push image arm64 |
| 59 | + uses: docker/build-push-action@v5 |
| 60 | + with: |
| 61 | + context: . |
| 62 | + file: Dockerfile.arm |
| 63 | + platforms: linux/arm64 |
| 64 | + push: false |
| 65 | + tags: | |
| 66 | + ${{ steps.compute-tags.outputs.tag_latest }} |
| 67 | + ${{ steps.compute-tags.outputs.tag_version }} |
0 commit comments