From 420cfe7365271e303118fc183329b8bc105248b0 Mon Sep 17 00:00:00 2001 From: Heidi Lammi-Mihaljov Date: Thu, 5 Dec 2024 16:14:33 +0200 Subject: [PATCH] OK-735: Testataan uin github deploymenttia --- .github/workflows/build.yml | 62 ++++++++++++++++++++++++++++++++++-- .github/workflows/deploy.yml | 48 ++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f9f7c8a..4dfa86f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,8 @@ on: - '**.md' jobs: - build: + # BACKEND + build-backend: runs-on: ubuntu-latest steps: @@ -47,7 +48,7 @@ jobs: cd ovara-backend mvn clean package -B -DskipTests - deploy-container: + deploy-backend-container: needs: build runs-on: ubuntu-latest @@ -78,3 +79,60 @@ jobs: ./ci-tools/common/pull-image.sh ./ci-tools/github-build/build-fatjar.sh $ARTIFACT_NAME ./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME + + # UI + lint: + timeout-minutes: 10 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install dependencies + run: npm ci + - name: Run lint + run: | + npm run typecheck + npm run lint + + test: + timeout-minutes: 10 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install dependencies + run: npm ci + - name: Run unit tests + run: npm test + + deploy-ui-zip: + needs: [lint, test] + timeout-minutes: 30 + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install dependencies + run: npm ci --no-audit --prefer-offline + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4 + with: + role-to-assume: ${{ secrets.AWS_OPH_UTILITY_ROLE_ARN }} + role-session-name: ovara-ui-deploy-zip + aws-region: eu-west-1 + - name: Deploy zip to s3 + env: + bucket: ${{ secrets.BUCKET_NAME }} + run: | + npm run build + zip -r ga-${{github.run_number}}.zip .next/*.* .next/BUILD_ID .next/static .next/standalone public + aws s3 cp --no-progress ga-${{github.run_number}}.zip s3://"$bucket"/ga-${{github.run_number}}.zip diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c16b01c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,48 @@ +name: Ovara UI deploy +permissions: + id-token: write + contents: read +on: + workflow_dispatch: + inputs: + build-number: + type: number + description: Github Actions build number + environment: + type: choice + description: Environment where to deploy + options: + - untuva + - hahtuva + - pallero +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install NPM dependencies + run: | + npm ci + cd cdk + npm ci + npm install -g aws-cdk + - name: Configure AWS credentials + if: ${{ inputs.environment == 'hahtuva' || inputs.environment == 'untuva' || inputs.environment == 'pallero' }} + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4 + with: + role-to-assume: ${{ secrets.AWS_OPINTOPOLKU_DEV_ROLE_ARN }} + role-session-name: ovara-ui-deploy + aws-region: eu-west-1 + - name: Download build from s3 + env: + bucket: ${{ secrets.BUCKET_NAME }} + run: | + aws s3 cp --no-progress s3://"$bucket"/ga-${{inputs.build-number}}.zip build.zip + unzip build.zip + - name: Deploy Next.js app + run: | + cd cdk + cdk deploy OvaraUISovellusStack --require-approval never -c "environment=${{ inputs.environment }}" -c "skipBuild=true"