Skip to content
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

chore: publish docker images to github's registry #61

Merged
merged 15 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 39 additions & 19 deletions .github/workflows/publish_images.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
name: Publish images
on:
workflow_dispatch:
workflow_run:
workflows: ["X-Road-Catalog tests"]
types: [completed]
branches: [develop, XRDCAT-28-**]
workflow_dispatch: {}
branches: [develop]
env:
REGISTRY: ghcr.io
XROAD_HOME: ${{ github.workspace }}
jobs:
BuildAndPublish:
name: Setup Environment
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Build and publish docker images
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-24.04
strategy:
matrix:
service: [collector, lister]
steps:
- name: Checkout source code
uses: actions/checkout@v4
Expand All @@ -35,26 +31,50 @@ jobs:
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-${{ matrix.service }}'s Docker Image
- name: Build and push xrddev-catalog-collector's Docker Image
uses: docker/build-push-action@v6
with:
context: ${{ github.workspace }}/docker/${{ matrix.service }}
context: ${{ github.workspace }}
file: ${{ github.workspace }}/docker/collector/Dockerfile
push: true
tags: ghcr.io/nordic-institute/xrddev-catalog-${{ matrix.service }}:latest
- name: Clean old ${{ matrix.service }} images
uses: snok/container-retention-policy@v2
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/container-retention-policy@v3.0.0
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/container-retention-policy@v3.0.0
with:
image-names: xrddev-catalog-${{ matrix.service }}
cut-off: 1 week ago UTC
account: nordic-institute
image-names: xrddev-catalog-lister
cut-off: 1w
timestamp-to-use: created_at
account-type: org
org-name: nordic-institute
keep-at-least: 1
token-type: github-token
keep-n-most-recent: 1
token: ${{ secrets.GITHUB_TOKEN }}
Loading