Skip to content

Authentication with docker login #130

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
21 changes: 11 additions & 10 deletions .github/workflows/build-and-deploy-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,26 @@ jobs:
if: inputs.tags != ''
run: echo "TAGS=-PdockerTags=${{ inputs.tags }}" >> $GITHUB_ENV

- name: Setup Docker Hub credentials
- name: Login to DockerHub
if: inputs.registry == 'docker.io'
run: |
echo "DOCKER_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" >> $GITHUB_ENV
echo "DOCKER_PASSWORD=${{ secrets.DOCKERHUB_TOKEN }}" >> $GITHUB_ENV
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Setup GitHub Container Registry credentials
- name: Login to GitHub Container Registry
if: inputs.registry == 'ghcr.io'
run: |
echo "DOCKER_USERNAME=${{ github.actor }}" >> $GITHUB_ENV
echo "DOCKER_PASSWORD=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and deploy OCI image
run: >
./gradlew bootBuildImage
-PjvmType=${{ inputs.image-jvm-type }}
-PjdkVersion=${{ inputs.image-jvm-version }}
-PdockerUsername=${{ env.DOCKER_USERNAME }}
-PdockerPassword=${{ env.DOCKER_PASSWORD }}
$TAGS
--imageName=${{ inputs.registry }}/${{ inputs.image-name }}
--publishImage
6 changes: 0 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {

val jdkVersion: String by project
val jvmType: String by project
val dockerUsername: String by project
val dockerPassword: String by project
val dockerTags: String? by project
val imageRegistry: String? by project
val imageName: String? by project
Expand Down Expand Up @@ -54,10 +52,6 @@ tasks {
"paketo-buildpacks/environment-variables",
"gcr.io/paketo-buildpacks/health-checker"
)
docker.publishRegistry {
username = dockerUsername
password = dockerPassword
}
environment = mapOf(
"BP_JVM_TYPE" to jvmType,
"BP_JVM_VERSION" to jdkVersion,
Expand Down