diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml index f09775b..64d4af4 100644 --- a/.github/workflows/docker-image.yaml +++ b/.github/workflows/docker-image.yaml @@ -4,8 +4,6 @@ on: push: branches: - "master" - tags: - - "v*.*.*" jobs: ghcr-build: @@ -19,6 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -27,26 +26,14 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.PRIVATE_TOKEN }} - # If it was a release tag, use the tag as the image tag, - # and otherwise image tag is the commit SHA - - name: Set image tag - run: | - if [[ $GITHUB_REF == refs/tags/v* ]]; then - echo "Labeling image with TAG: ${GITHUB_REF#refs/tags/v}" - echo "IMAGE_TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - echo "RELEASE_TAG=,ghcr.io/${IMAGE_NAME}:latest" >> $GITHUB_ENV - else - echo "Labeling image with commit SHA: ${GITHUB_SHA}" - echo "IMAGE_TAG=${GITHUB_SHA}" >> $GITHUB_ENV - fi - - name: Push to GitHub Container Registry - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile push: true - tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}${{ env.RELEASE_TAG }} + platforms: linux/amd64,linux/arm64 + tags: ghcr.io/${{ env.IMAGE_NAME }}:canary-${{ github.sha }} docker-build: @@ -60,6 +47,7 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v3 - name: Login to DockerHub uses: docker/login-action@v1 @@ -68,21 +56,11 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set image tag - run: | - if [[ $GITHUB_REF == refs/tags/v* ]]; then - echo "Labeling image with TAG: ${GITHUB_REF#refs/tags/v}" - echo "IMAGE_TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - echo "RELEASE_TAG=,docker.io/${IMAGE_NAME}:latest" >> $GITHUB_ENV - else - echo "Labeling image with commit SHA: ${GITHUB_SHA}" - echo "IMAGE_TAG=canary-${GITHUB_SHA}" >> $GITHUB_ENV - fi - - name: Push to DockerHub - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile push: true - tags: docker.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}${{ env.RELEASE_TAG }} \ No newline at end of file + platforms: linux/amd64,linux/arm64 + tags: docker.io/${{ env.IMAGE_NAME }}:canary-${{ github.sha }} \ No newline at end of file diff --git a/.github/workflows/release-image.yaml b/.github/workflows/release-image.yaml new file mode 100644 index 0000000..5c48226 --- /dev/null +++ b/.github/workflows/release-image.yaml @@ -0,0 +1,66 @@ +name: Build Docker Image + +on: + push: + tags: + - "v*.*.*" + +jobs: + ghcr-build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + env: + IMAGE_NAME: shahradelahi/wireadmin + + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.PRIVATE_TOKEN }} + + - name: Push to GitHub Container Registry + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ghcr.io/${{ env.IMAGE_NAME }}:latest,ghcr.io/${{ env.IMAGE_NAME }}:${GITHUB_REF#refs/tags/v} + + + docker-build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + env: + IMAGE_NAME: litehex/wireadmin + + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push to DockerHub + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: docker.io/${{ env.IMAGE_NAME }}:latest,docker.io/${{ env.IMAGE_NAME }}:${GITHUB_REF#refs/tags/v}