Skip to content

Commit

Permalink
Feat: enhance Docker workflow with versioning and multi-registry support
Browse files Browse the repository at this point in the history
  • Loading branch information
kek-Sec committed Dec 19, 2024
1 parent 59209f0 commit b08cc75
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/build-and-push-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,41 @@ jobs:
- name: πŸš€ Checkout Code
uses: actions/checkout@v4

#get version from version.yaml
#if on main tag should be the semver from version.yaml
#if on PR tag should be rc-semver-PR_NUMBER

# Get version from version.yaml
- name: πŸ“ Get version
run: |
echo "VERSION=$(cat version.yaml | sed -n 's/version: //p')" >> $GITHUB_ENV
#print the version
echo $VERSION
# Set build tags based on branch
- name: πŸ—οΈ Set Build tags
run: |
if [ $GITHUB_REF = 'refs/heads/main' ]; then
echo "IMAGE_TAGS=$VERSION" >> $GITHUB_ENV
else
echo "IMAGE_TAGS=rc-$VERSION-$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
fi
- name: πŸ› οΈ Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Login to GitHub Container Registry
- name: πŸ” Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}

# Login to Docker Hub
- name: πŸ” Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Build and Push Image to GitHub and Docker Hub
- name: πŸ“¦ Build and Push Image
uses: docker/build-push-action@v4
with:
Expand All @@ -58,6 +64,7 @@ jobs:
push: true
tags: |
ghcr.io/kek-sec/gopherdrop:${{ env.IMAGE_TAGS }}
petrakisg/gopherdrop:${{ env.IMAGE_TAGS }}
annotations: |
org.opencontainers.image.description=GopherDrop, a secure one-time secret sharing service
build-args: |
Expand Down

0 comments on commit b08cc75

Please sign in to comment.