Skip to content

Commit

Permalink
Fix to support default_branch (Doesn't work `github.event.repository.…
Browse files Browse the repository at this point in the history
…default_branch`)
  • Loading branch information
tnasu committed Nov 26, 2021
1 parent 21c65f1 commit 375b1ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
DEFAULT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$DEFAULT_BRANCH" = "$VERSION" ]; then
VERSION=latest
fi
fi
Expand All @@ -34,13 +35,13 @@ jobs:
fi
echo ::set-output name=tags::${TAGS}
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
# - name: Set up QEMU
# uses: docker/setup-qemu-action@master
# with:
# platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1

# - name: Login to DockerHub
# if: ${{ github.event_name != 'pull_request' }}
Expand All @@ -49,11 +50,11 @@ jobs:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish to Docker Hub
uses: docker/build-push-action@v2
with:
context: .
file: ./DOCKER/Dockerfile
platforms: linux/amd64,linux/arm64
#push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
# - name: Publish to Docker Hub
# uses: docker/build-push-action@v2
# with:
# context: .
# file: ./DOCKER/Dockerfile
# platforms: linux/amd64,linux/arm64
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.prep.outputs.tags }}
29 changes: 16 additions & 13 deletions .github/workflows/proto-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
pull_request:
paths:
- "tools/proto/*"
# push:
# paths:
# - "tools/proto/*"
push:
branches:
- main
paths:
- "tools/proto/*"
schedule:
# run this job once a month to recieve any go or buf updates
- cron: "* * 1 * *"
Expand All @@ -24,26 +26,27 @@ jobs:
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
DEFAULT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$DEFAULT_BRANCH" = "$VERSION" ]; then
VERSION=latest
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
echo ::set-output name=tags::${TAGS}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1

# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish to Docker Hub
uses: docker/build-push-action@v2
with:
context: ./tools/proto
file: ./tools/proto/Dockerfile
push: false #${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
# - name: Publish to Docker Hub
# uses: docker/build-push-action@v2
# with:
# context: ./tools/proto
# file: ./tools/proto/Dockerfile
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.prep.outputs.tags }}

0 comments on commit 375b1ae

Please sign in to comment.