diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13c53a9..576085a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,13 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: actions/cache@v4 + id: restore-build + with: + path: | + ovara-backend/target + key: ${{ github.sha }} + - name: Cache local Maven repository uses: actions/cache@v4 with: @@ -39,3 +46,37 @@ jobs: run: | cd ovara-backend mvn clean package -B -DskipTests + + deploy-container: + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/cache@v4 + id: restore-build + with: + path: | + ovara-backend/target + key: ${{ github.sha }} + + - name: Build and deploy Docker container + shell: bash + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: | + set -euo pipefail + git clone https://github.com/Opetushallitus/ci-tools.git + source ci-tools/common/setup-tools.sh + export ARTIFACT_NAME="ovara-backend" + export BASE_IMAGE="baseimage-fatjar-openjdk21:master" + source ci-tools/common/setup-tools.sh + printf "HELLO\n" + ls ovara-backend + mv ovara-backend/target/ovara-backend-*.jar $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}.jar + cp -vr ovara-backend/src/main/resources/application.properties $DOCKER_BUILD_DIR/config/ + ./ci-tools/common/pull-image.sh + ./ci-tools/github-build/build-fatjar.sh $ARTIFACT_NAME + ./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME