Skip to content

Build+Test(+Push) run 666 from pull_request (oppimaaran-kielitarkenne) #666

Build+Test(+Push) run 666 from pull_request (oppimaaran-kielitarkenne)

Build+Test(+Push) run 666 from pull_request (oppimaaran-kielitarkenne) #666

Workflow file for this run

name: Build+Test(+Push)
run-name: ${{ github.workflow }} run ${{github.run_number}} from ${{github.event_name}} (${{github.head_ref || github.ref_name}})
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-(${{github.ref}}-${{github.event_name}}
cancel-in-progress: true
jobs:
code_check:
runs-on: "ubuntu-22.04"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn
- name: yarn install
run: yarn install --frozen-lockfile
- name: Code check
uses: ./.github/actions/code_check
build-jar-and-test-api:
runs-on: "ubuntu-22.04"
permissions:
id-token: write
contents: read
checks: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn
- name: yarn install
run: yarn install --frozen-lockfile
- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: zulu
- name: Start database for API tests
run: docker compose up -d
- name: Configure untuva AWS credentials
uses: aws-actions/configure-aws-credentials@v2 # More information on this action can be found below in the 'AWS Credentials' section
with:
role-to-assume: arn:aws:iam::782034763554:role/ludos-github-actions-role-untuva
aws-region: eu-west-1
- name: Gradle build, including API tests
uses: gradle/gradle-build-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
arguments: build
build-root-directory: server
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: gradle-test-report
path: server/build/test-results/test/TEST-*.xml
reporter: java-junit
- uses: actions/upload-artifact@v3
if: always()
with:
name: build-debug-artifacts
path: |
server/build/reports/
retention-days: 7
- uses: actions/upload-artifact@v3
with:
name: jar
path: server/build/libs/ludos.jar
retention-days: 30
if-no-files-found: error
playwright:
runs-on: "ubuntu-22.04"
needs: [ "build-jar-and-test-api" ]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Playwright
uses: ./.github/actions/playwright
with:
ludos-profiles: local
testikayttaja-yllapitaja-username: ${{ secrets.TESTIKAYTTAJA_YLLAPITAJA_USERNAME }}
testikayttaja-yllapitaja-password: ${{ secrets.TESTIKAYTTAJA_YLLAPITAJA_PASSWORD }}
ludos-palvelukayttaja-username: ${{ secrets.LUDOS_PALVELUKAYTTAJA_USERNAME }}
ludos-palvelukayttaja-password: ${{ secrets.LUDOS_PALVELUKAYTTAJA_PASSWORD }}
build-docker-image-and-push:
runs-on: "ubuntu-22.04"
needs: [ "build-jar-and-test-api", "playwright" ]
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' || github.run_attempt >= 2
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- name: calculate short sha
id: short-sha
run: echo "short-sha=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: get branch name
id: branch-name
run: echo "branch-name=${{ github.event.pull_request && github.head_ref || github.ref_name }}" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v3
with:
name: jar
path: server/build/libs
- name: Configure utility AWS credentials
uses: aws-actions/configure-aws-credentials@v2 # More information on this action can be found below in the 'AWS Credentials' section
with:
role-to-assume: arn:aws:iam::505953557276:role/ludos-gh-actions-ecr-push-role
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Calculate image tag
id: image-tag
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ludos
IMAGE_TAG: ludos-${{ github.run_number }}-${{ steps.branch-name.outputs.branch-name }}-${{ steps.short-sha.outputs.short-sha }}
run: |
echo "image-tag=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
echo "image-tag-with-registry=${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
echo "::notice title=Image tag::${{ env.IMAGE_TAG }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
file: docker-build/Dockerfile
context: .
tags: ${{ steps.image-tag.outputs.image-tag-with-registry }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max