env vars #9
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: Test and Containerize | |
on: | |
push: | |
paths-ignore: | |
- CHANGELOG.md | |
- README.md | |
- CONTRIBUTING.md | |
- LICENSE | |
- renovate.json | |
- docker-compose.yml | |
- Dockerfile | |
workflow_dispatch: | |
env: | |
YGGDRASIL_VERSION: 0.0.0 | |
jobs: | |
# https://stackoverflow.com/questions/67288526/github-actions-replace-character-in-string | |
# https://github.com/orgs/community/discussions/45488 | |
set-vars: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.gen_version.outputs.VERSION }} | |
steps: | |
- name: set values | |
id: gen_version | |
run: | | |
echo "VERSION=${GITHUB_REF_NAME////_}" >> $GITHUB_OUTPUT | |
build-and-test: | |
needs: [set-vars] | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
container: | |
image: eclipse-temurin:21 | |
env: | |
# Tell scripts assume an non-interactive shell. This keeps logs clean | |
# in case of e.g. progress bars that would cause one line for each state, otherwise | |
TERM: dumb | |
YGGDRASIL_VERSION: "${{ needs.set-vars.outputs.VERSION }}" | |
ports: | |
- "8899:8080" | |
env: | |
YGGDRASIL_VERSION: "${{ needs.set-vars.outputs.VERSION }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Create the jar | |
run: ./gradlew | |
- name: Run checks and tests | |
run: ./gradlew check | |
- name: Upload analysis to GitHub | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: check-results | |
path: | | |
yggdrasil-cartago/build/reports | |
yggdrasil-core/build/reports | |
yggdrasil-utils/build/reports | |
yggdrasil-websub/build/reports | |
build/reports | |
if-no-files-found: error | |
- name: Make structure for app | |
run: cp build/libs/yggdrasil-${{ env.YGGDRASIL_VERSION }}-SNAPSHOT-all.jar . | |
- name: Upload app to GitHub | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: app | |
path: | | |
conf/docker_disk_config.json | |
yggdrasil-${{ env.YGGDRASIL_VERSION }}-SNAPSHOT-all.jar | |
if-no-files-found: error | |
containerize: | |
needs: [set-vars, build-and-test] | |
environment: "containerized_debugging" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
env: | |
YGGDRASIL_VERSION: "${{ needs.set-vars.outputs.VERSION }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# WARNING: https://stackoverflow.com/a/57877438 is suggesting to use '@master' | |
# however due to change from "master" to "main", "master" is outdated | |
- uses: actions/download-artifact@v3 | |
id: download | |
with: | |
# Omitting name to download all artifacts | |
# Skipping '/' is on purpose since 'ADD' in Dockerfile cannot use abs path | |
path: opt/ | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
build-args: | | |
YGGDRASIL_VERSION=${{ env.YGGDRASIL_VERSION }} | |
push: true | |
tags: galess/ics-hsg-yggdrasil:${{ env.YGGDRASIL_VERSION }} |