Add temporary test workflow to test deployment of image #1
Workflow file for this run
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: Push Release Docker Image to Public Harbor | |
on: push | |
jobs: | |
create-release: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: 774df1c7a71bdca0191d72cd93ecdd34de381b8b | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: 'oracle' | |
- name: Set up node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.17.0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Store short commit hash | |
run: echo "SHORT_COMMIT_HASH=774df1c" >> $GITHUB_ENV | |
- name: Store semver version | |
run: echo "SEMVER_VERSION=0.0.1" >> $GITHUB_ENV | |
- name: Set New Snapshot Version | |
run: mvn build-helper:parse-version versions:set -DnewVersion=${{ env.SEMVER_VERSION }}-SNAPSHOT -DgenerateBackupPoms=false | |
- name: Build JAR with mvn package | |
run: mvn clean package -Dtest=\!CypressE2ETest | |
- name: Build the docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
tags: harbor.puzzle.ch/pitc-mobility-public/uni-luzern:${{ env.SEMVER_VERSION }}.${{ env.SHORT_COMMIT_HASH }} | |
load: true | |
push: false | |
outputs: type=docker,dest=/tmp/okr-docker-image.tar | |
- name: Load image | |
run: docker load --input /tmp/okr-docker-image.tar | |
- name: Run docker image | |
run: docker run --rm -v ./static:/resources -p 8080:8080 harbor.puzzle.ch/pitc-mobility-public/uni-luzern:${{ env.SEMVER_VERSION }}.${{ env.SHORT_COMMIT_HASH }} & | |
- name: Cypress run e2e tests | |
uses: cypress-io/github-action@v6 | |
with: | |
build: npm i -D cypress | |
install: false | |
wait-on: 'http://localhost:8080/' | |
wait-on-timeout: 120 | |
browser: chrome | |
headed: false | |
working-directory: src/test/e2e | |
config: baseUrl=http://localhost:8080 | |
- name: Create release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "${{ env.SEMVER_VERSION }}.${{ env.SHORT_COMMIT_HASH }}" | |
release_name: uni-luzern-eft | |
draft: false | |
prerelease: false | |
- name: Login to Harbor Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: harbor.puzzle.ch | |
username: ${{ secrets.PUB_HARBOR_USERNAME }} | |
password: ${{ secrets.PUB_HARBOR_TOKEN }} | |
- name: Push the docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile | |
tags: harbor.puzzle.ch/pitc-mobility-public/uni-luzern:${{ env.short_hash }} | |
push: true |