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

Development: Add Helios-based deployment workflow for test servers and reusable build logic #10109

Merged
merged 83 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
67aaaea
remove label related action
egekocabas Jan 5, 2025
9113263
remove lock related part in pr closed event
egekocabas Jan 5, 2025
bec6ae6
update build and deployment to test servers workflows to work with He…
egekocabas Jan 6, 2025
5c06c6f
do not send GITHUB_TOKEN to build action
egekocabas Jan 6, 2025
69851d8
change pr number input to string
egekocabas Jan 6, 2025
6eb4b22
fix deployment
egekocabas Jan 6, 2025
2c04b61
override raw_url
egekocabas Jan 6, 2025
02b86b4
fix deployment
egekocabas Jan 6, 2025
24a3905
fix deployment
egekocabas Jan 6, 2025
1d01371
fix deployment
egekocabas Jan 6, 2025
673fd33
provide raw_url to deployment workflow & also add commenting on build…
egekocabas Jan 6, 2025
1e4532d
fix build call in deployment workflow
egekocabas Jan 6, 2025
173a7e8
debugging
egekocabas Jan 6, 2025
d169d34
fix build step and fix skipping rest of the steps
egekocabas Jan 6, 2025
86fd750
fix build step
egekocabas Jan 6, 2025
6a9fedf
fix build step
egekocabas Jan 6, 2025
629c661
fix build step
egekocabas Jan 6, 2025
8760d77
fix build step
egekocabas Jan 6, 2025
c33994a
seperate build.yml and build-reusable.yml
egekocabas Jan 6, 2025
1d8619a
rename action
egekocabas Jan 6, 2025
971274d
remove reusable build workflow and include build script into the depl…
egekocabas Jan 6, 2025
fdabbc4
concat build (branch) and check build status (PR)
egekocabas Jan 6, 2025
9dc62cf
fix build
egekocabas Jan 6, 2025
662a366
test
egekocabas Jan 6, 2025
8737496
Merge branch 'develop' into feature/testserver-deployments-with-helios
egekocabas Jan 6, 2025
499aa54
separate helios deployment file
egekocabas Jan 11, 2025
ee095af
revert
egekocabas Jan 11, 2025
9837d33
revert
egekocabas Jan 11, 2025
2c4a8a3
Merge branch 'develop' into feature/testserver-deployments-with-helios
egekocabas Jan 11, 2025
d7d3e75
rename workflow
egekocabas Jan 11, 2025
70fa0b1
update description
egekocabas Jan 11, 2025
cc48077
update on action
egekocabas Jan 17, 2025
b032833
remove sticky comments and refactor concurrency
egekocabas Jan 17, 2025
60d1ef2
convert build.yml to reusable workflow for helios
egekocabas Jan 17, 2025
fe33327
testing deployment
egekocabas Jan 17, 2025
78681e8
fix dependency
egekocabas Jan 17, 2025
c27e67f
fix
egekocabas Jan 17, 2025
6e42417
fix
egekocabas Jan 17, 2025
35974c4
remove filtering of environments
egekocabas Jan 17, 2025
8b5cdbc
add environment url
egekocabas Jan 17, 2025
5852997
fix deployment
egekocabas Jan 17, 2025
40abb24
test - print env variables
egekocabas Jan 17, 2025
b89f534
use vars of environment
egekocabas Jan 17, 2025
77485c7
clear comment out
egekocabas Jan 17, 2025
b1365a4
log paylaod in build
egekocabas Jan 17, 2025
d79f775
log in build
egekocabas Jan 17, 2025
47b17b3
log in build
egekocabas Jan 17, 2025
1042e5e
log in build
egekocabas Jan 17, 2025
4f1e495
use parents variable
egekocabas Jan 17, 2025
1395d11
add explanation
egekocabas Jan 17, 2025
fee3707
use new action file
egekocabas Jan 17, 2025
9376e1e
Merge branch 'develop' into feature/testserver-deployments-with-helios
egekocabas Jan 17, 2025
d63de40
revert
egekocabas Jan 17, 2025
639f013
revert
egekocabas Jan 17, 2025
73c55a3
Update .github/workflows/testserver-helios.yml
egekocabas Jan 19, 2025
92f24f0
update raw_url description
egekocabas Jan 19, 2025
448a1df
rename deployment action file name
egekocabas Jan 23, 2025
9d74714
add reusable build action
egekocabas Jan 23, 2025
96ee3dc
refactor build.yml to use reusable build action
egekocabas Jan 23, 2025
a4a2260
fix string - boolean type mismatch
egekocabas Jan 24, 2025
2227744
use $GITHUB_OUTPUT instead of deprecated set-output
egekocabas Jan 24, 2025
a04168f
fix missing quotes
egekocabas Jan 24, 2025
60e8a1e
add descriptions to build.yml
egekocabas Jan 24, 2025
62e100e
update helios deployment workflow
egekocabas Jan 24, 2025
7ed2456
refactor
egekocabas Jan 24, 2025
5f18bb1
add todo for input validation
egekocabas Jan 24, 2025
add2b32
workflow testing setup
egekocabas Jan 24, 2025
48bb441
fix
egekocabas Jan 24, 2025
89429c9
fix missing job output & refactor
egekocabas Jan 24, 2025
3e51773
fix docker tag for deployments from a branch which doesn't have a PR
egekocabas Jan 24, 2025
bc9ec2c
fix
egekocabas Jan 24, 2025
eaa228e
update reusable-build workflow
egekocabas Jan 24, 2025
1b52a11
update reusable-build workflow
egekocabas Jan 24, 2025
1128f23
Merge branch 'develop' into feature/testserver-deployments-with-helios
egekocabas Jan 24, 2025
825fcb1
update reusable-build workflow
egekocabas Jan 24, 2025
8d9203d
rename
egekocabas Jan 24, 2025
925a07f
revert testserver.yml to original and move content to new workflow
egekocabas Jan 24, 2025
5f2dcc7
revert spaces
egekocabas Jan 24, 2025
fa5862c
revert spaces
egekocabas Jan 24, 2025
40aef2d
add missing docker input usage
egekocabas Jan 25, 2025
efc12f9
use native arm runner for reusable-build.yml
egekocabas Jan 28, 2025
d3c41af
use outputs instead of push input to docker/build-push-action version 6
egekocabas Jan 28, 2025
fc5089e
revert to the previous reusable build action
egekocabas Jan 28, 2025
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
192 changes: 87 additions & 105 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,118 +31,100 @@ on:
types:
- created

# Keep in sync with codeql-analysis.yml and test.yml and analysis-of-endpoint-connections.yml
env:
CI: true
node: 22
java: 21
RAW_URL: https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}
# Keep this filename in sync with the filename environment variable (PR_AUTO_BUILD_FILE_NAME) in the testserver-deployment.yml workflow

jobs:

build:
name: Build .war artifact
define-inputs:
name: Define Inputs
runs-on: ubuntu-latest
outputs:
release_upload: ${{ steps.set-upload-release.outputs.release_upload }}
release_url: ${{ steps.set-upload-release.outputs.release_url }}
release_path: ${{ steps.set-upload-release.outputs.release_path }}
release_name: ${{ steps.set-upload-release.outputs.release_name }}
release_type: ${{ steps.set-upload-release.outputs.release_type }}
docker_build: ${{ steps.set-docker-build.outputs.docker_build }}
docker_ref: ${{ steps.set-docker-ref.outputs.docker_ref }}
docker_build_tag: ${{ steps.set-docker-tag.outputs.docker_build_tag }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '${{ env.node }}'
cache: 'npm'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '${{ env.java }}'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Production Build
run: ./gradlew -Pprod -Pwar clean bootWar
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Artemis.war
path: build/libs/Artemis-*.war
- name: Upload Release Artifact
if: github.event_name == 'release' && github.event.action == 'created'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: build/libs/Artemis-${{ github.event.release.tag_name }}.war
asset_name: Artemis.war
asset_content_type: application/x-webarchive
- name: Set Upload Release Artifact Outputs
id: set-upload-release
run: |
# If event is release created, set the release_upload flag and the release artifact details
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "created" ]]; then
echo "release_upload=true" >> $GITHUB_OUTPUT
echo "release_url=${{ github.event.release.upload_url }}" >> $GITHUB_OUTPUT
echo "release_path=build/libs/Artemis-${{ github.event.release.tag_name }}.war" >> $GITHUB_OUTPUT
echo "release_name=Artemis.war" >> $GITHUB_OUTPUT
echo "release_type=application/x-webarchive" >> $GITHUB_OUTPUT
else
echo "release_upload=false" >> $GITHUB_OUTPUT
fi

docker:
name: Build and Push Docker Image
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'ls1intum/Artemis' }}
runs-on: ubuntu-latest
steps:
- name: Compute Tag
uses: actions/github-script@v7
id: compute-tag
with:
result-encoding: string
script: |
if (context.eventName === "pull_request") {
return "pr-" + context.issue.number;
}
if (context.eventName === "release") {
return "latest";
}
if (context.eventName === "push") {
if (context.ref.startsWith("refs/tags/")) {
return context.ref.slice(10);
- name: Set Docker Build Flag
id: set-docker-build
run: |
if [[ ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'ls1intum/Artemis' }} ]]; then
echo "docker_build=true" >> $GITHUB_OUTPUT
else
echo "docker_build=false" >> $GITHUB_OUTPUT
fi

- name: Set Docker ref
if: ${{ steps.set-docker-build.outputs.docker_build == 'true' }}
id: set-docker-ref
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Checkout pull request HEAD commit instead of merge commit
# this is done to include the correct branch and git information inside the build
echo "docker_ref=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "push" ]]; then
echo "docker_ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi

- name: Compute Docker Tag
if: ${{ steps.set-docker-build.outputs.docker_build == 'true' }}
uses: actions/github-script@v7
id: compute-tag
with:
result-encoding: string
script: |
if (context.eventName === "pull_request") {
return "pr-" + context.issue.number;
}
if (context.eventName === "release") {
return "latest";
}
if (context.ref === "refs/heads/develop") {
return "develop";
if (context.eventName === "push") {
if (context.ref.startsWith("refs/tags/")) {
return context.ref.slice(10);
}
if (context.ref === "refs/heads/develop") {
return "develop";
}
}
}
return "FALSE";
- name: Git Checkout for PRs
if: ${{ github.event_name == 'pull_request' }}
# Checkout pull request HEAD commit instead of merge commit
# this is done to include the correct branch and git information inside the build
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Git Checkout for push actions
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Git Checkout for push actions
if: ${{ github.event_name == 'release' }}
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Build and Push to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: ${{ steps.compute-tag.outputs.result != 'FALSE' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push to GitHub Container Registry
uses: docker/build-push-action@v5
if: ${{ steps.compute-tag.outputs.result != 'FALSE' }}
with:
# beware that the linux/arm64 build from the registry is using an amd64 compiled .war file as
# the GitHub runners don't support arm64 and QEMU takes too long for emulating the build
platforms: linux/amd64,linux/arm64
file: ./docker/artemis/Dockerfile
context: .
tags: ghcr.io/ls1intum/artemis:${{ steps.compute-tag.outputs.result }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=min
return "FALSE";

- name: Set Docker Tag
id: set-docker-tag
run: |
if [[ ${{ steps.compute-tag.outputs.result != 'FALSE' }} ]]; then
echo "docker_build_tag=${{ steps.compute-tag.outputs.result }}" >> $GITHUB_OUTPUT
fi

# TODO: Push to Docker Hub (develop + tag)

# TODO: Push to Chair Harbour (??)
call-build-workflow:
name: Call Build Workflow
needs: define-inputs
uses: ./.github/workflows/reusable-build.yml
with:
build_war: true
release_upload: ${{ needs.define-inputs.outputs.release_upload == 'true' }}
release_url: ${{ needs.define-inputs.outputs.release_url }}
release_path: ${{ needs.define-inputs.outputs.release_path }}
release_name: ${{ needs.define-inputs.outputs.release_name }}
release_type: ${{ needs.define-inputs.outputs.release_type }}
docker: true
docker_ref: ${{ needs.define-inputs.outputs.docker_ref }}
docker_build_tag: ${{ needs.define-inputs.outputs.docker_build_tag }}
193 changes: 193 additions & 0 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Build

on:
workflow_call:
inputs:
# Build job inputs
build_war:
description: "Whether to build and upload the .war artifact."
required: false
default: false
type: boolean
build_ref:
description: "Branch name, tag, or commit SHA to use for the build job. If not provided, it falls back to the default behavior of actions/checkout."
required: false
default: ''
type: string

# Upload Release Artifact job inputs
release_upload:
description: "Whether to upload the release artifact."
required: false
default: false
type: boolean
release_url:
description: "URL to upload the release artifact to."
required: false
default: ''
type: string
release_path:
description: "Path to the release artifact."
required: false
default: ''
type: string
release_name:
description: "Name of the release artifact."
required: false
default: ''
type: string
release_type:
description: "Content type of the release artifact."
required: false
default: ''
type: string

# Docker job inputs
docker:
description: "Whether to build and push a Docker image."
required: false
default: false
type: boolean
docker_ref:
description: "Branch name, tag, or commit SHA to use for the Docker job. If not provided, it falls back to the default behavior of actions/checkout."
required: false
default: ''
type: string
docker_build_tag:
description: "Tag to use when building Docker image."
required: false
default: ''
type: string

# Keep in sync with codeql-analysis.yml and test.yml and analysis-of-endpoint-connections.yml
env:
CI: true
node: 22
java: 21

jobs:
validate-inputs:
name: Validate Inputs
runs-on: ubuntu-latest
steps:
- name: Validate Inputs
run: |
# Check release related inputs
if [[ "${{ github.event.inputs.release_upload }}" ]]; then
# List of required release inputs
missing_inputs=()

# Check each required input
[[ -z "${{ inputs.release_url }}" || "${{ inputs.release_url }}" == '' ]] && missing_inputs+=("release_url")
[[ -z "${{ inputs.release_path }}" || "${{ inputs.release_path }}" == '' ]] && missing_inputs+=("release_path")
[[ -z "${{ inputs.release_name }}" || "${{ inputs.release_name }}" == '' ]] && missing_inputs+=("release_name")
[[ -z "${{ inputs.release_type }}" || "${{ inputs.release_type }}" == '' ]] && missing_inputs+=("release_type")

if [[ "${#missing_inputs[@]}" -gt 0 ]]; then
echo "::error::Release upload is set to true, but the following inputs are missing: ${missing_inputs[*]}"
exit 1
fi
fi

# Check Docker related inputs
if [[ "${{ github.event.inputs.docker }}" ]]; then
# Check whether all Docker inputs are set
if [[ "${{ github.event.inputs.docker_build_tag }}" == '' ]]; then
echo "::error::Docker build is set to true, but Docker build tag is not set."
exit 1
fi
fi


build:
name: Build .war artifact
if: ${{ inputs.build_war }}
needs: validate-inputs
runs-on: ubuntu-latest
steps:
# Git Checkout
- name: Git Checkout to the specific ref (if build_ref is set)
uses: actions/checkout@v4
if: ${{ inputs.build_ref != '' }}
with:
ref: ${{ inputs.build_ref }}
- name: Git Checkout (default)
uses: actions/checkout@v4
if: ${{ inputs.build_ref == '' }}
# Setup Node.js, Java and Gradle
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '${{ env.node }}'
cache: 'npm'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '${{ env.java }}'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
# Build
- name: Production Build
run: ./gradlew -Pprod -Pwar clean bootWar
# Upload Artifact
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Artemis.war
path: build/libs/Artemis-*.war
# Upload Artifact (Release)
- name: Upload Release Artifact
if: ${{ inputs.release_upload }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.release_url }}
asset_path: ${{ inputs.release_path }}
asset_name: ${{ inputs.release_name }}
asset_content_type: ${{ inputs.release_type }}

docker:
name: Build and Push Docker Image
if: ${{ inputs.docker }}
needs: validate-inputs
runs-on: ubuntu-latest
steps:
# Git Checkout
- name: Git Checkout to the specific ref (if docker_ref is set)
uses: actions/checkout@v4
if: ${{ inputs.docker_ref != '' }}
with:
ref: ${{ inputs.docker_ref }}
- name: Git Checkout (default)
uses: actions/checkout@v4
if: ${{ inputs.docker_ref == '' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Build and Push to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push to GitHub Container Registry
uses: docker/build-push-action@v5
with:
# beware that the linux/arm64 build from the registry is using an amd64 compiled .war file as
# the GitHub runners don't support arm64 and QEMU takes too long for emulating the build
platforms: linux/amd64,linux/arm64
file: ./docker/artemis/Dockerfile
context: .
tags: ghcr.io/ls1intum/artemis:${{ inputs.docker_build_tag }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=min

# TODO: Push to Docker Hub (develop + tag)

# TODO: Push to Chair Harbour (??)
Loading
Loading