Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update dockerhub push flow #27

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/dockerhub-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,31 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set Environment Variables
run: |
BRANCH_NAME=$(echo $GITHUB_REF | awk -F'/' '{print $3}')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x src/${{ env.BRANCH_NAME }}-service/gradlew

- name: Build with Gradle
run: |
cd src/${{ env.BRANCH_NAME }}-service
./gradlew clean build

- name: Build and Push Docker Image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
run: |
# Extract branch name from GITHUB_REF
BRANCH_NAME=$(echo $GITHUB_REF | awk -F'/' '{print $3}')

if [ -n "$BRANCH_NAME" ]; then
DOCKERFILE_DIR="src/$BRANCH_NAME-service"
else
Expand All @@ -34,4 +51,3 @@ jobs:
docker build -t $DOCKER_USERNAME/$BRANCH_NAME-service:latest .
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push $DOCKER_USERNAME/$BRANCH_NAME-service:latest

Loading