-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make github workflow build and publish a runnable restape image
- Loading branch information
1 parent
c447bb8
commit e28b1a1
Showing
5 changed files
with
203 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
############################## | ||
## Java | ||
############################## | ||
.mtj.tmp/ | ||
*.class | ||
*.jar | ||
*.war | ||
*.ear | ||
*.nar | ||
hs_err_pid* | ||
|
||
############################## | ||
## Maven | ||
############################## | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
pom.xml.bak | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
.mvn/wrapper/maven-wrapper.jar | ||
|
||
############################## | ||
## Gradle | ||
############################## | ||
bin/ | ||
/bin/ | ||
build/ | ||
.gradle | ||
.gradletasknamecache | ||
gradle-app.setting | ||
!gradle-wrapper.jar | ||
|
||
############################## | ||
## IntelliJ | ||
############################## | ||
out/ | ||
.idea/ | ||
.idea_modules/ | ||
*.iml | ||
*.ipr | ||
*.iws | ||
|
||
############################## | ||
## Eclipse | ||
############################## | ||
.settings/ | ||
/.settings/ | ||
bin/ | ||
tmp/ | ||
.metadata | ||
.classpath | ||
.project | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.loadpath | ||
.factorypath | ||
|
||
############################## | ||
## NetBeans | ||
############################## | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
nbactions.xml | ||
nb-configuration.xml | ||
|
||
############################## | ||
## Visual Studio Code | ||
############################## | ||
.vscode/ | ||
|
||
############################## | ||
## OS X | ||
############################## | ||
.DS_Store | ||
/lib/ | ||
/apeOutputs/ | ||
/https:/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
day: "monday" | ||
- package-ecosystem: docker | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
day: "monday" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: ghcr actions | ||
|
||
on: | ||
schedule: | ||
- cron: "21 21 * * *" | ||
|
||
jobs: | ||
clean-ghcr: | ||
name: Delete old unused container images | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- name: downcase REPO name | ||
run: | | ||
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | ||
- name: Delete 'PR' containers older than a week | ||
uses: snok/[email protected] | ||
with: | ||
image-names: ${{ env.REGISTRY }}/${{ env.REPO }} | ||
filter-tags: sha-*,sha256:* | ||
skip-tags: latest | ||
cut-off: A week ago UTC | ||
account-type: org | ||
org-name: ${{ github.repository_owner }} | ||
keep-at-least: 1 | ||
token: ${{ secrets.GH_REPO_TOKEN }} | ||
timestamp-to-use: updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Build and Publish | ||
|
||
on: [push] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: downcase REPO name | ||
run: | | ||
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.REPO }} | ||
tags: | | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=sha,enable=true,priority=100,prefix=sha-,suffix=,format=short | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: | | ||
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | ||
org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
org.opencontainers.image.revision=${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
FROM eclipse-temurin:17-jdk-jammy | ||
FROM maven:3-eclipse-temurin-17 AS builder | ||
|
||
WORKDIR /app | ||
COPY restape-0.2.4.jar /app | ||
ENTRYPOINT ["java", "-jar", "restape-0.2.4.jar"] | ||
|
||
COPY pom.xml pom.xml | ||
|
||
RUN --mount=type=cache,target=/root/.m2 \ | ||
mvn -f pom.xml dependency:resolve | ||
|
||
COPY . . | ||
|
||
RUN --mount=type=cache,target=/root/.m2 \ | ||
mvn -f pom.xml clean package | ||
|
||
|
||
FROM eclipse-temurin:17-jre-jammy | ||
|
||
WORKDIR /app | ||
COPY --from=builder /app/target/*.jar /app/runner.jar | ||
|
||
ENTRYPOINT ["java", "-jar", "/app/runner.jar"] |