-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/4 ci setup #6
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
Changes from all commits
e313cd9
5983d5a
5535cf7
abf89a9
1603734
a06aec3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,85 @@ | ||||||||||||||||||||||||||||
| name: CI | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||
| branches: [ "main" ] | ||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||
| branches: [ "main" ] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||
| packages: write | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||
| REGISTRY: ghcr.io | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||
| build-and-push: | ||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Set up JDK | ||||||||||||||||||||||||||||
| uses: actions/setup-java@v4 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| distribution: "temurin" | ||||||||||||||||||||||||||||
| java-version: "17" | ||||||||||||||||||||||||||||
| cache: gradle | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Copy application.yml into runner | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| mkdir -p src/main/resources | ||||||||||||||||||||||||||||
| echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Build + Test(Gradle) | ||||||||||||||||||||||||||||
| if: ${{ hashFiles('**/build.gradle*') != '' }} | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| chmod +x ./gradlew | ||||||||||||||||||||||||||||
| ./gradlew clean test | ||||||||||||||||||||||||||||
| ./gradlew bootJar | ||||||||||||||||||||||||||||
| JAR=$(ls build/libs/*.jar | head -n 1) | ||||||||||||||||||||||||||||
| cp "$JAR" app.jar | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Compute image name (change to lowercase) | ||||||||||||||||||||||||||||
| id: img | ||||||||||||||||||||||||||||
| run: echo "name=${{ env.REGISTRY }}/${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Log in to GHCR | ||||||||||||||||||||||||||||
| uses: docker/login-action@v3 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| registry: ${{ env.REGISTRY }} | ||||||||||||||||||||||||||||
| username: ${{ github.actor }} | ||||||||||||||||||||||||||||
| password: ${{ secrets.GHCR_TOKEN }} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip GHCR login when secrets are unavailable on forked PRs.
- name: Log in to GHCR
- uses: docker/login-action@v3
+ if: ${{ github.event_name != 'pull_request' && github.secret_source == 'Actions' }}
+ uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||
| - name: Extract Docker metadata (tags, labels) | ||||||||||||||||||||||||||||
| id: meta | ||||||||||||||||||||||||||||
| uses: docker/metadata-action@v5 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| images: ${{ steps.img.outputs.name }} | ||||||||||||||||||||||||||||
| tags: | | ||||||||||||||||||||||||||||
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||||||||||||||||||||||||||||
| type=ref,event=tag | ||||||||||||||||||||||||||||
| type=sha | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Set up Docker Build | ||||||||||||||||||||||||||||
| uses: docker/setup-buildx-action@v3 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Debug paths | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| pwd | ||||||||||||||||||||||||||||
| ls -la | ||||||||||||||||||||||||||||
| find . -maxdepth 3 -iname 'Dockerfile' -print | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Build and push | ||||||||||||||||||||||||||||
| uses: docker/build-push-action@v6 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| context: . | ||||||||||||||||||||||||||||
| file: ./Dockerfile | ||||||||||||||||||||||||||||
| push: ${{ github.event_name != 'pull_request' }} | ||||||||||||||||||||||||||||
| tags: ${{ steps.meta.outputs.tags }} | ||||||||||||||||||||||||||||
| labels: ${{ steps.meta.outputs.labels }} | ||||||||||||||||||||||||||||
| cache-from: type=gha | ||||||||||||||||||||||||||||
| cache-to: type=gha,mode=max | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM eclipse-temurin:17-jre-alpine | ||
| WORKDIR /app | ||
| COPY app.jar app.jar | ||
| EXPOSE 8080 | ||
| ENTRYPOINT ["java", "-jar", "app.jar"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying the wrong JAR breaks the container runtime.
ls build/libs/*.jar | head -n 1grabs the first alphabetic match, which is the*-plain.jarGradle produces alongside the runnablebootJar. That thin artifact lacks dependencies, sojava -jar app.jardies at runtime. Filter out the-plainvariant (and fail fast if no runnable jar exists) before copying.Apply this diff:
π Committable suggestion
π€ Prompt for AI Agents