Skip to content

Commit c9f5b60

Browse files
committed
Authentication with docker login
1 parent d3aa683 commit c9f5b60

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

.github/workflows/build-and-deploy-image.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,26 @@ jobs:
5959
if: inputs.tags != ''
6060
run: echo "TAGS=-PdockerTags=${{ inputs.tags }}" >> $GITHUB_ENV
6161

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

68-
- name: Setup GitHub Container Registry credentials
69-
if: inputs.registry == 'ghcr.io'
70-
run: |
71-
echo "DOCKER_USERNAME=${{ github.actor }}" >> $GITHUB_ENV
72-
echo "DOCKER_PASSWORD=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
69+
- name: Login to GitHub Container Registry
70+
if: env.REGISTRY == 'ghcr.io'
71+
uses: docker/login-action@v3
72+
with:
73+
registry: ghcr.io
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
7376

7477
- name: Build and deploy OCI image
7578
run: >
7679
./gradlew bootBuildImage
7780
-PjvmType=${{ inputs.image-jvm-type }}
7881
-PjdkVersion=${{ inputs.image-jvm-version }}
79-
-PdockerUsername=${{ env.DOCKER_USERNAME }}
80-
-PdockerPassword=${{ env.DOCKER_PASSWORD }}
8182
$TAGS
8283
--imageName=${{ inputs.registry }}/${{ inputs.image-name }}
8384
--publishImage

build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ plugins {
88

99
val jdkVersion: String by project
1010
val jvmType: String by project
11-
val dockerUsername: String by project
12-
val dockerPassword: String by project
1311
val dockerTags: String? by project
1412
val imageRegistry: String? by project
1513
val imageName: String? by project
@@ -54,10 +52,6 @@ tasks {
5452
"paketo-buildpacks/environment-variables",
5553
"gcr.io/paketo-buildpacks/health-checker"
5654
)
57-
docker.publishRegistry {
58-
username = dockerUsername
59-
password = dockerPassword
60-
}
6155
environment = mapOf(
6256
"BP_JVM_TYPE" to jvmType,
6357
"BP_JVM_VERSION" to jdkVersion,

0 commit comments

Comments
 (0)