Skip to content

Commit

Permalink
Use Dockerhub credentials for workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte-Hansen committed Jan 7, 2025
1 parent 328af44 commit 71a59fe
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 56 deletions.
17 changes: 8 additions & 9 deletions .github/actions/build-and-deploy-quarkus-jvm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ inputs:
required: true
outputs: {}
runs:
using: 'composite'
using: "composite"
steps:
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Log in to GitHub Container Registry
distribution: "temurin"
java-version: "11"
- name: Log in to Docker Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Quarkus JVM Image
shell: sh
run: |
Expand All @@ -30,5 +29,5 @@ runs:
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.name=${{ inputs.image-name }} \
-Dquarkus.container-image.tag=${{ inputs.image-tag }} \
-Dquarkus.container-image.username=${{ secrets.DOCKERHUB_USERNAME }} \
-Dquarkus.container-image.password=${{ secrets.DOCKERHUB_PASSWORD }}
-Dquarkus.container-image.username=${{ secrets.DOCKER_USERNAME }} \
-Dquarkus.container-image.password=${{ secrets.DOCKER_PASSWORD }}
19 changes: 9 additions & 10 deletions .github/actions/build-and-deploy-quarkus-native/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ inputs:
required: true
outputs: {}
runs:
using: 'composite'
using: "composite"
steps:
- name: Set up graalvm
uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '21'
- name: Log in to GitHub Container Registry
distribution: "graalvm"
java-version: "21"
- name: Log in to Docker Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.reg-username }}
password: ${{ inputs.reg-token }}
username: ${{ inputs.reg-username }}
password: ${{ inputs.reg-token }}
- name: Build Quarkus Native Image
shell: sh
run: |
Expand All @@ -37,6 +36,6 @@ runs:
-Dquarkus.container-image.name=${{ inputs.image-name }} \
-Dquarkus.container-image.tag=${{ inputs.image-tag }} \
-Dquarkus.native.additional-build-args="--initialize-at-run-time=org.apache.kafka.common.security.authenticator.SaslClientAuthenticator\,org.apache.kafka.common.security.oauthbearer.internals.expiring.ExpiringCredentialRefreshingLogin" \
# -Dquarkus.container-image.username=${{ secrets.DOCKERHUB_USERNAME }} \
#-Dquarkus.container-image.password=${{ secrets.DOCKERHUB_PASSWORD }}
# -Dquarkus.container-image.username=${{ secrets.DOCKER_USERNAME }} \
#-Dquarkus.container-image.password=${{ secrets.DOCKER_PASSWORD }}
8 changes: 4 additions & 4 deletions .github/actions/retag-dockerhub-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ inputs:
required: true
outputs: {}
runs:
using: 'composite'
using: "composite"
steps:
- name: Install Crane
shell: sh
shell: sh
run: |
curl -sSL https://github.com/google/go-containerregistry/releases/download/v0.9.0/go-containerregistry_Linux_x86_64.tar.gz | tar xz -C /usr/local/bin crane
- name: Retag Image
shell: sh
run: |
crane auth login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} index.docker.io
crane cp ${{ secrets.DOCKERHUB_ORGANIZATION }}/${{ inputs.image-name }}:${{ inputs.source-tag }} ${{ secrets.DOCKERHUB_ORGANIZATION }}/${{ inputs.image-name }}:${{ inputs.target-tag }}
crane auth login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} index.docker.io
crane cp ${{ inputs.image-name }}:${{ inputs.source-tag }} ${{ inputs.image-name }}:${{ inputs.target-tag }}
66 changes: 33 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
pull_request:
branches:
- '**'
- "**"

env:
IMAGE_REGISTRY: ghcr.io/hu1buerger/explorviz-span-service # TODO: set in github as env var
Expand All @@ -22,8 +22,8 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '21'
distribution: "graalvm"
java-version: "21"

- name: Cache Gradle Packages
uses: actions/cache@v4
Expand All @@ -47,8 +47,8 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '21'
distribution: "graalvm"
java-version: "21"

- name: Cache Gradle Packages
uses: actions/cache@v4
Expand All @@ -70,8 +70,8 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '21'
distribution: "graalvm"
java-version: "21"

- name: Cache Gradle Packages
uses: actions/cache@v4
Expand All @@ -93,8 +93,8 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '21'
distribution: "graalvm"
java-version: "21"

- name: Cache Gradle Packages
uses: actions/cache@v4
Expand All @@ -117,8 +117,8 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '21'
distribution: "graalvm"
java-version: "21"

- name: Cache Gradle Packages
uses: actions/cache@v4
Expand All @@ -129,8 +129,8 @@ jobs:
- name: Run Integration Tests
run: ./gradlew integrationTest

- uses: actions/upload-artifact@v4 # upload test results
if: success() || failure() # run this step even if previous step failed
- uses: actions/upload-artifact@v4 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results-integration
path: build/reports/tests/integrationTest/index.html
Expand All @@ -144,10 +144,10 @@ jobs:
steps:
- uses: dorny/test-reporter@v1
with:
artifact: /test-results-(.*)/ # artifact name
name: java-junit # Name of the check run which will be created
path: '*.html' # Path to test results (inside artifact .zip)
reporter: jest-junit # Format of test results
artifact: /test-results-(.*)/ # artifact name
name: java-junit # Name of the check run which will be created
path: "*.html" # Path to test results (inside artifact .zip)
reporter: jest-junit # Format of test results

test:
name: test end node
Expand All @@ -169,10 +169,10 @@ jobs:
- name: Build and Deploy Quarkus Native Image
uses: ./.github/actions/build-and-deploy-quarkus-native
with:
image-name: ${{ env.IMAGE_REGISTRY }}
image-tag: 'amd64'
reg-username: ${{ github.actor }}
reg-token: ${{ secrets.GITHUB_TOKEN }}
image-name:${{ vars.DOCKER_IMAGE_NAME }}
image-tag: "amd64"
reg-username: ${{ secrets.DOCKER_USERNAME }}
reg-token: ${{ secrets.DOCKER_PASSWORD }}

push-dockerhub-native-main-arm64:
name: Push Native Image (ARM64)
Expand All @@ -193,10 +193,10 @@ jobs:
- name: Build and Deploy Quarkus Native Image
uses: ./.github/actions/build-and-deploy-quarkus-native
with:
image-name: ${{ env.IMAGE_REGISTRY }}
image-tag: 'arm64'
reg-username: ${{ github.actor }}
reg-token: ${{ secrets.GITHUB_TOKEN }}
image-name:${{ vars.DOCKER_IMAGE_NAME }}
image-tag: "arm64"
reg-username: ${{ secrets.DOCKER_USERNAME }}
reg-token: ${{ secrets.DOCKER_PASSWORD }}

docker-image-native:
name: Docker image native
Expand All @@ -215,15 +215,15 @@ jobs:
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup ARM64 Emulation
run: |
sudo apt-get update
sudo apt-get install -y qemu binfmt-support qemu-user-static
docker run --privileged --rm tonistiigi/binfmt --install all
- run: quarkus image push --native --registry ghcr.io --registry-username=${{ github.actor }} --registry-password=${{ secrets.GITHUB_TOKEN }} --group ${{github.repository_owner}} -Dquarkus.container-image.builder=docker -D quarkus.docker.buildx.platform=linux/amd64,linux/arm64
- run: quarkus image push --native --registry ghcr.io --registry-username=${{ secrets.DOCKER_USERNAME }} --registry-password=${{ secrets.DOCKER_PASSWORD }} --group ${{github.repository_owner}} -Dquarkus.container-image.builder=docker -D quarkus.docker.buildx.platform=linux/amd64,linux/arm64
docker-image-jvm:
name: Docker image JVM
runs-on: ubuntu-latest
Expand All @@ -240,8 +240,8 @@ jobs:
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup ARM64 Emulation for multi arch build
run: |
sudo apt-get update
Expand All @@ -250,8 +250,8 @@ jobs:
- run: |
quarkus image push \
--registry ghcr.io \
--registry-username=${{ github.actor }} \
--registry-password=${{ secrets.GITHUB_TOKEN }} \
--registry-username=${{ secrets.DOCKER_USERNAME }} \
--registry-password=${{ secrets.DOCKER_PASSWORD }} \
--group ${{github.repository_owner}} \
-Dquarkus.container-image.builder=docker \
-D quarkus.docker.buildx.platform=linux/amd64,linux/arm64

0 comments on commit 71a59fe

Please sign in to comment.