Skip to content

Commit

Permalink
Split up test and push github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jacomago committed Sep 27, 2024
1 parent 41874ba commit dc62ad7
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 64 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# 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.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Build and Push

on:
push:
branches: [ "master" ]
tags:
- '**'

permissions:
contents: read
checks: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-jar-release:
name: Build Default site version
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew assemble
env:
ARCHAPPL_SITEID: "default"
- name: Upload package
if: always()
uses: actions/upload-artifact@v4
with:
name: default-package
path: build/distributions/*.tar.gz

build-and-push-image:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
imagetag:
- singletomcat
- mgmt
- etl
- engine
- retrieval
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew assemble
env:
ARCHAPPL_SITEID: "default"
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
prefix=${{matrix.imagetag}}-
tags: |
type=ref,event=pr,prefix=${{ matrix.imagetag }}-pr-
type=sha,prefix=${{ matrix.imagetag }}-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
target: ${{matrix.imagetag}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
66 changes: 2 additions & 64 deletions .github/workflows/ci.yml → .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Test and Build
name: Test and Build Test Versions

on:
push:
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
siteid: ["slacdev", "default"]
siteid: ["slacdev", "default", "tests"]

steps:
- uses: actions/checkout@v4
Expand All @@ -125,65 +125,3 @@ jobs:
with:
name: ${{ matrix.siteid }}-package
path: build/distributions/*.tar.gz

build-and-push-image:
needs: [unittests, epicstests]
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
imagetag:
- singletomcat
- mgmt
- etl
- engine
- retrieval
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew assemble
env:
ARCHAPPL_SITEID: "default"
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
prefix=${{matrix.imagetag}}-
tags: |
type=ref,event=pr,prefix=${{ matrix.imagetag }}-pr-
type=sha,prefix=${{ matrix.imagetag }}-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
target: ${{matrix.imagetag}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit dc62ad7

Please sign in to comment.