Skip to content

resolve ci-cd docker login username #8

resolve ci-cd docker login username

resolve ci-cd docker login username #8

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches:
- main
- 'feature/**'
- 'bugfix/**'
pull_request:
branches:
- main
- 'feature/**'
- 'bugfix/**'
jobs:
tests:
name: Tests Runner
runs-on: ubuntu-latest
steps:
- name: Source Code Checkout
uses: actions/checkout@v2
- name: JDK Configure
uses: actions/setup-java@v2
with:
java-version: "17"
distribution: "temurin"
- name: Run application tests
run: ./gradlew test
build:
name: Build application
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Build with Gradle Wrapper
run: ./gradlew clean build -x test
- name: Set build tag
run: echo "BUILD_TAG=$(echo ${{ github.head_ref || github.ref }} | sed 's,/,_,g')-${{ github.run_number }}" >> $GITHUB_ENV
- name: Print BUILD_TAG
run: echo "Branch ---> ${{ github.head_ref || github.ref }}" && echo "Tag ---> ${{ env.BUILD_TAG }}"
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: deyvisonborges
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: VERSION=${{ env.BUILD_TAG }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/your-image-name:${{ env.BUILD_TAG }}