Skip to content

Commit b198ce1

Browse files
authored
Merge branch 'vegardit:main' into main
2 parents b5f17dd + 349ee80 commit b198ce1

20 files changed

+444
-225
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ updates:
1212
prefix-development: chore
1313
include: scope
1414
labels:
15-
- gha
15+
- pinned
1616
- dependencies
17+
- gha

.github/stale.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 94 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
1-
# Copyright 2020-2021 by Vegard IT GmbH, Germany, https://vegardit.com
1+
# SPDX-FileCopyrightText: © Vegard IT GmbH (https://vegardit.com)
2+
# SPDX-FileContributor: Sebastian Thomschke
23
# SPDX-License-Identifier: Apache-2.0
4+
# SPDX-ArtifactOfProjectHomePage: https://github.com/vegardit/docker-graalvm-maven
35
#
4-
# Author: Sebastian Thomschke, Vegard IT GmbH
5-
#
6-
# https://github.com/vegardit/docker-graalvm-maven
7-
#
8-
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
6+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
97
name: Build
108

119
on:
1210
push:
13-
branches:
11+
branches: # build all branches
1412
- '**'
15-
tags-ignore:
13+
tags-ignore: # but don't build tags
1614
- '**'
1715
paths-ignore:
16+
- '**/*.adoc'
1817
- '**/*.md'
18+
- '.editorconfig'
19+
- '.git*'
20+
- '.github/*.yml'
21+
- '.github/workflows/stale.yml'
1922
schedule:
2023
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
21-
- cron: '0 0 * * *'
24+
- cron: '0 4 * * */3' # At 04:00 on every 3rd day-of-week
25+
pull_request:
2226
workflow_dispatch:
2327
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
28+
inputs:
29+
GRAALVM_VERSION:
30+
description: 'GraalVM Version'
31+
required: true
32+
default: 'latest'
33+
34+
defaults:
35+
run:
36+
shell: bash
2437

2538
env:
2639
DOCKER_IMAGE_REPO: vegardit/graalvm-maven
2740
TRIVY_CACHE_DIR: ~/.trivy/cache
28-
41+
2942
jobs:
3043
build:
3144
runs-on: ubuntu-latest
@@ -35,17 +48,34 @@ jobs:
3548
fail-fast: false
3649
matrix:
3750
include:
38-
- GRAALVM_VERSION: release
51+
# https://github.com/graalvm/graalvm-ce-builds/releases
52+
- GRAALVM_VERSION: ${{ github.event.inputs.GRAALVM_VERSION || 'latest' }}
53+
GRAALVM_JAVA_VERSION: 11
54+
experimental: false
55+
- GRAALVM_VERSION: ${{ github.event.inputs.GRAALVM_VERSION || 'latest' }}
56+
GRAALVM_JAVA_VERSION: 17
3957
experimental: false
40-
- GRAALVM_VERSION: latest
58+
- GRAALVM_VERSION: ${{ github.event.inputs.GRAALVM_VERSION || 'latest' }}
59+
GRAALVM_JAVA_VERSION: 21
60+
experimental: false
61+
- GRAALVM_VERSION: ${{ github.event.inputs.GRAALVM_VERSION || 'latest' }}
62+
GRAALVM_JAVA_VERSION: 24
63+
experimental: false
64+
# https://github.com/graalvm/graalvm-ce-dev-builds/releases
65+
- GRAALVM_VERSION: dev
66+
GRAALVM_JAVA_VERSION: 25
4167
experimental: true
4268

4369
steps:
70+
- name: Show environment variables
71+
run: env | sort
72+
4473
- name: Git Checkout
45-
uses: actions/checkout@v3 #https://github.com/actions/checkout
74+
uses: actions/checkout@v4 #https://github.com/actions/checkout
4675

4776
- name: Cache trivy cache
48-
uses: actions/cache@v3
77+
uses: actions/cache@v4
78+
if: env.ACT != 'true' # https://github.com/nektos/act#skipping-steps
4979
with:
5080
path: ${{ env.TRIVY_CACHE_DIR }}
5181
# https://github.com/actions/cache/issues/342#issuecomment-673371329
@@ -54,39 +84,40 @@ jobs:
5484
${{ runner.os }}-trivy-
5585
5686
- name: Cache local Maven repository
57-
uses: actions/cache@v3
87+
uses: actions/cache@v4
88+
if: env.ACT != 'true' # https://github.com/nektos/act#skipping-steps
5889
with:
5990
path: /tmp/maven-repo
6091
key: ${{ runner.os }}-mvnrepo-${{ hashFiles('example/pom.xml') }}
6192
restore-keys: |
6293
${{ runner.os }}-mvnrepo-
6394
95+
- name: Configure fast APT repository mirror
96+
uses: vegardit/fast-apt-mirror.sh@v1
97+
6498
- name: Install dos2unix
65-
# using '-o Acquire::Retries=3' to workaround sporadic connectivity issues "Could not connect to azure.archive.ubuntu.com:80"
66-
# see https://github.com/actions/virtual-environments/issues/675
67-
run: sudo apt-get install -o Acquire::Retries=3 --no-install-recommends -y dos2unix
99+
run: sudo apt-get install --no-install-recommends -y dos2unix
68100

69-
- name: Build ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}
70-
shell: bash
101+
- name: Build ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}-java${{ matrix.GRAALVM_JAVA_VERSION }}
71102
env:
72103
DOCKER_REGISTRY: docker.io
73104
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
74105
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
106+
GITHUB_TOKEN: ${{ github.token }}
75107
GRAALVM_VERSION: ${{ matrix.GRAALVM_VERSION }}
108+
GRAALVM_JAVA_VERSION: ${{ matrix.GRAALVM_JAVA_VERSION }}
76109
TRIVY_GITHUB_TOKEN: ${{ github.token }}
77110
run: |
78-
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
111+
set -eu
112+
if [[ $GITHUB_REF_NAME == "main" && $GITHUB_EVENT_NAME != "pull_request" && ${ACT:-} != "true" ]]; then
79113
export DOCKER_PUSH=1
114+
echo "$DOCKER_REGISTRY_TOKEN" | docker login -u="$DOCKER_REGISTRY_USERNAME" "$DOCKER_REGISTRY" --password-stdin
80115
fi
81-
echo "$DOCKER_REGISTRY_TOKEN" | docker login -u="$DOCKER_REGISTRY_USERNAME" "$DOCKER_REGISTRY" --password-stdin
82116
bash build-image.sh
83117
84-
- name: Test ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}
85-
shell: bash
86-
env:
87-
DOCKER_IMAGE: ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}
118+
- name: Test ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}-java${{ matrix.GRAALVM_JAVA_VERSION }}
88119
run: |
89-
docker run --rm -t vegardit/graalvm-maven:release /bin/bash -c "
120+
docker run --rm -t ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}-java${{ matrix.GRAALVM_JAVA_VERSION }} /bin/bash -c "
90121
cd /tmp
91122
echo 'class HelloWorld { public static void main(String[] args) { System.out.println(\"HelloWorld!\"); }}' > HelloWorld.java
92123
javac HelloWorld.java
@@ -96,15 +127,46 @@ jobs:
96127
./helloworld
97128
98129
# test static executable
99-
native-image --static HelloWorld
130+
native-image HelloWorld
100131
./helloworld
101132
"
102133
103-
- name: Test ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }} via Maven
104-
shell: bash
134+
- name: Test ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}-java${{ matrix.GRAALVM_JAVA_VERSION }} via Maven
105135
env:
106-
DOCKER_IMAGE: ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}
136+
RUN_IN_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE_REPO }}:${{ matrix.GRAALVM_VERSION }}-java${{ matrix.GRAALVM_JAVA_VERSION }}
137+
if: ${{ !env.ACT }} # https://github.com/nektos/act#skipping-steps
107138
run: |
139+
set -eux
108140
bash example/tools/run-in-docker.sh mvn clean package
109141
bash example/tools/run-in-docker.sh bash -c target/example
110-
142+
143+
- name: Publish Docker image to GH registry
144+
if: ${{ github.ref_name == 'main' && github.event_name != 'pull_request' && !env.ACT }} # https://github.com/nektos/act#skipping-steps
145+
run: |
146+
set -eux
147+
148+
echo "${{ github.token }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
149+
150+
image_name="$DOCKER_IMAGE_REPO:${{ matrix.GRAALVM_VERSION }}-java${{ matrix.GRAALVM_JAVA_VERSION }}"
151+
docker image tag $image_name ghcr.io/$image_name
152+
docker push ghcr.io/$image_name
153+
154+
purge-untagged-images:
155+
runs-on: ubuntu-latest
156+
needs: [build]
157+
steps:
158+
- name: Delete untagged images
159+
uses: actions/github-script@v7
160+
if: ${{ github.ref_name == 'main' && github.event_name != 'pull_request' && !env.ACT }} # https://github.com/nektos/act#skipping-steps
161+
with:
162+
github-token: ${{ secrets.GHA_DELETE_PACKAGES }}
163+
script: |
164+
const imageName = /[^/]*$/.exec(process.env.DOCKER_IMAGE_REPO)[0]
165+
const basePath = `/orgs/${{ github.repository_owner }}/packages/container/${imageName}/versions`
166+
for (version of (await github.request(`GET ${basePath}`, { per_page: 100 })).data) {
167+
if (version.metadata.container.tags.length == 0) {
168+
console.log(`deleting ${version.name}...`)
169+
const delResponse = await github.request(`DELETE ${basePath}/${version.id}`)
170+
console.log(`status: ${delResponse.status}`)
171+
}
172+
}

.github/workflows/stale.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-FileCopyrightText: © Sebastian Thomschke and contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
# SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanzeigen-bot/
4+
#
5+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
6+
name: Stale issues
7+
8+
on:
9+
schedule:
10+
- cron: '0 16 * * *'
11+
workflow_dispatch:
12+
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
13+
14+
permissions:
15+
contents: write # only for delete-branch option
16+
issues: write
17+
pull-requests: write
18+
19+
jobs:
20+
stale:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Git checkout
25+
uses: actions/checkout@v4 # https://github.com/actions/checkout
26+
27+
- name: Run stale action
28+
uses: actions/stale@v9 # https://github.com/actions/stale
29+
with:
30+
repo-token: ${{ secrets.GITHUB_TOKEN }}
31+
days-before-stale: 90
32+
days-before-close: 14
33+
stale-issue-message: >
34+
This issue has been automatically marked as stale because it has not had
35+
recent activity. It will be closed in 14 days if no further activity occurs.
36+
If the issue is still valid, please add a respective comment to prevent this
37+
issue from being closed automatically. Thank you for your contributions.
38+
stale-issue-label: stale
39+
close-issue-label: wontfix
40+
exempt-issue-labels: |
41+
enhancement
42+
pinned
43+
security
44+
45+
- name: Run stale action
46+
uses: actions/stale@v9 # https://github.com/actions/stale
47+
with:
48+
repo-token: ${{ secrets.GITHUB_TOKEN }}
49+
days-before-stale: 360
50+
days-before-close: 14
51+
stale-issue-message: >
52+
This issue has been automatically marked as stale because it has not had
53+
recent activity. It will be closed in 14 days if no further activity occurs.
54+
If the issue is still valid, please add a respective comment to prevent this
55+
issue from being closed automatically. Thank you for your contributions.
56+
stale-issue-label: stale
57+
close-issue-label: wontfix
58+
only-labels: enhancement
59+
exempt-issue-labels: |
60+
pinned
61+
security

.trivyignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# secrets - false positive
2+
github-app-token

0 commit comments

Comments
 (0)