Publish images #32
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
name: Publish images | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: ["X-Road-Catalog tests"] | |
types: [completed] | |
branches: [develop] | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
BuildAndPublish: | |
name: Build and publish docker images | |
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
cache-read-only: ${{ github.ref != 'refs/heads/develop' }} | |
cache-cleanup: always | |
dependency-graph: generate-and-submit | |
add-job-summary-as-pr-comment: always | |
- name: Build JARs (skipping tests) | |
run: ./gradlew --no-daemon build -x test | |
- name: List JAR files | |
run: ls -lah xroad-catalog-collector/build/libs xroad-catalog-lister/build/libs | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push xrddev-catalog-collector's Docker Image | |
uses: docker/build-push-action@v6 | |
with: | |
context: ${{ github.workspace }} | |
file: ${{ github.workspace }}/docker/collector/Dockerfile | |
push: true | |
tags: ghcr.io/nordic-institute/xrddev-catalog-collector:latest | |
- name: Build and push xrddev-catalog-lister's Docker Image | |
uses: docker/build-push-action@v6 | |
with: | |
context: ${{ github.workspace }} | |
file: ${{ github.workspace }}/docker/lister/Dockerfile | |
push: true | |
tags: ghcr.io/nordic-institute/xrddev-catalog-lister:latest | |
CleanOldImages: | |
name: Clean old docker images | |
if: ${{ needs.BuildAndPublish.result == 'success' }} | |
needs: BuildAndPublish | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Clean old xrddev-catalog-collector's Docker Images | |
uses: snok/[email protected] | |
with: | |
account: nordic-institute | |
image-names: xrddev-catalog-collector | |
cut-off: 1w | |
timestamp-to-use: created_at | |
keep-n-most-recent: 1 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Clean old xrddev-catalog-lister's Docker Images | |
uses: snok/[email protected] | |
with: | |
account: nordic-institute | |
image-names: xrddev-catalog-lister | |
cut-off: 1w | |
timestamp-to-use: created_at | |
keep-n-most-recent: 1 | |
token: ${{ secrets.GITHUB_TOKEN }} |