From e4b91337f0d45edb83557e58621b7b3e173cd328 Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Thu, 17 Mar 2022 12:22:02 +0100 Subject: [PATCH 01/10] chore(ci): change from circle ci to github actions --- .../frontend-build-and-publish-lib.yml | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 .github/workflows/frontend-build-and-publish-lib.yml diff --git a/.github/workflows/frontend-build-and-publish-lib.yml b/.github/workflows/frontend-build-and-publish-lib.yml new file mode 100644 index 00000000..b849b71a --- /dev/null +++ b/.github/workflows/frontend-build-and-publish-lib.yml @@ -0,0 +1,168 @@ +name: Frontend Build and Publish Library +on: + workflow_call: + inputs: + node-version: + description: Node version to use (defaults to 14) + required: false + type: string + default: '14' + junit-report-path: + description: The path to unit test report (defaults to ./junit/) + required: false + type: string + default: ./junit/ + junit-report-name: + description: The file name for unit test report (defaults to test-results.xml) + required: false + type: string + default: test-results.xml + aws-region: + description: Which AWS region to use for publish storybook (defaults to eu-west-1) + required: false + type: string + default: eu-west-1 + secrets: + npm-token: + required: true + aws-access-key-id: + required: true + aws-secret-access-key: + required: true +jobs: + build: + name: Build and publish library + runs-on: ubuntu-latest + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + always-auth: true + registry-url: https://www.myget.org/F/river-tech/npm/ + scope: '@odin' + + - name: Print environment versions + run: | + NODE_V=$(node --version) + NPM_V=$(npm -v) + echo node version':' $NODE_V + echo npm version':' $NPM_V + + - name: Checkout + uses: actions/checkout@v3.0.0 + + - name: Install npm + run: npm ci + env: + NODE_AUTH_TOKEN: ${{ secrets.npm-token }} + + - name: Build + run: npm run build + + - name: Test + run: npm run test -- --browsers=ChromeHeadlessCI --no-watch --no-progress + + - name: Build storybook + run: npm run build:storybook + + - name: Check if commit is publishable + id: commit + run: | + if git log --format=%B -n 1 | egrep "^(style|test|docs)"; then + echo "::set-output name=publishable::false" + echo "This update doesn't need to be published; finishing build..." + else + echo "::set-output name=publishable::true" + fi + + - name: Fetch git tags + if: ${{ steps.commit.outputs.publishable == 'true' }} + run: | + git fetch --prune --unshallow --tags + + - name: Check if tag exists + id: tag + if: ${{ steps.commit.outputs.publishable == 'true' }} + run: | + TAG=$(node -p "require('./lerna.json').version") + if git tag --list | grep "^$TAG$"; then + echo "::set-output name=publishable::false" + echo "Tag already exists. Please make sure you bump version!" + else + echo "::set-output name=publishable::true" + fi + + - name: Configure AWS credentials + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.aws-access-key-id }} + aws-secret-access-key: ${{ secrets.aws-secret-access-key }} + aws-region: ${{ inputs.aws-region }} + + - name: Login to Amazon ECR + id: login-ecr + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + uses: aws-actions/amazon-ecr-login@v1 + + - name: Publish storybook + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + env: + ECR_HOST: ${{ steps.login-ecr.outputs.registry }} + run: | + TAG=$(node -p "require('./storybook/package.json').version") + if $GITHUB_REF_NAME == 'develop' + then + TAG=$TAG-dev-$GITHUB_RUN_ID + elif [[ $GITHUB_REF_NAME =~ ^feature\/(.*)$ ]] + then + TAG=$TAG-demo-${BASH_REMATCH[1]}-$GITHUB_RUN_ID + fi + + [[ $ECR_HOST =~ ^([0-9]*) ]] && REGISTRY=${BASH_REMATCH[1]} + + if aws ecr describe-images --repository-name=odin.ngx-storybook --registry-id $REGISTRY --image-ids=imageTag=$TAG > /dev/null 2>&1; then + echo "$TAG already exists on remote... skipping..." + exit 0 + fi + + npm run build:storybook + + TAG=$TAG docker-compose build + TAG=$TAG docker-compose push + + if ! ([ $GITHUB_REF_NAME = "master" ] || [[ $GITHUB_REF_NAME =~ ^([0-9].*)\.x$ ]]); then + echo "PUBLISHABLE=false" >> $GITHUB_ENV + echo "Non-publishable branch; finishing build..." + fi + + - name: Logout of Amazon ECR + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + run: docker logout ${{ steps.login-ecr.outputs.registry }} + + - name: Deploy + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + run: | + echo "git tag" + PACKAGE_VERSION=$(node -p "require('./lerna.json').version") + git tag $PACKAGE_VERSION + git push --tags + npm run publish:rel + + - name: Store tests artifact + uses: actions/upload-artifact@v3 + if: failure() + with: + name: ${{ env.junit-report-name }} + path: ${{ env.junit-report-path }} + retention-days: 2 + + - name: Store npm artifact + uses: actions/upload-artifact@v3 + if: failure() + with: + name: npm-logs + path: ~/.npm/_logs/* + retention-days: 2 + From 95d9b52c6dc652d974afe6082d1049e8b5e61586 Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Thu, 17 Mar 2022 13:59:04 +0100 Subject: [PATCH 02/10] fix comments --- .../frontend-build-and-publish-lib.yml | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/.github/workflows/frontend-build-and-publish-lib.yml b/.github/workflows/frontend-build-and-publish-lib.yml index b849b71a..74ac9294 100644 --- a/.github/workflows/frontend-build-and-publish-lib.yml +++ b/.github/workflows/frontend-build-and-publish-lib.yml @@ -7,6 +7,16 @@ on: required: false type: string default: '14' + npm-registry-url: + description: The url address for npm registry (defaults to https://www.myget.org/F/river-tech/npm/) + required: false + type: string + default: https://www.myget.org/F/river-tech/npm/ + npm-registry-scope: + description: The name of the npm scope (defaults to @odin) + required: false + type: string + default: '@odin' junit-report-path: description: The path to unit test report (defaults to ./junit/) required: false @@ -39,8 +49,8 @@ jobs: with: node-version: ${{ inputs.node-version }} always-auth: true - registry-url: https://www.myget.org/F/river-tech/npm/ - scope: '@odin' + registry-url: ${{ inputs.npm-registry-url }} + scope: ${{ inputs.npm-registry-scope }} - name: Print environment versions run: | @@ -71,30 +81,32 @@ jobs: run: | if git log --format=%B -n 1 | egrep "^(style|test|docs)"; then echo "::set-output name=publishable::false" - echo "This update doesn't need to be published; finishing build..." + echo "::notice ::This update doesn't need to be published." else echo "::set-output name=publishable::true" fi - - name: Fetch git tags + - name: Fetch tag from lerna + id: lerna if: ${{ steps.commit.outputs.publishable == 'true' }} run: | - git fetch --prune --unshallow --tags + TAG=$(node -p "require('./lerna.json').version") + echo "::set-output name=tag::${TAG}" - name: Check if tag exists + uses: mukunku/tag-exists-action@v1.0.0 id: tag - if: ${{ steps.commit.outputs.publishable == 'true' }} - run: | - TAG=$(node -p "require('./lerna.json').version") - if git tag --list | grep "^$TAG$"; then - echo "::set-output name=publishable::false" - echo "Tag already exists. Please make sure you bump version!" - else - echo "::set-output name=publishable::true" - fi + with: + tag: ${{ steps.lerna.outputs.tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Inform if tag exists + if: ${{ steps.tag.outputs.exists == 'true' }} + run: echo "::notice ::Tag already exists. Please make sure you bump version!" - name: Configure AWS credentials - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.aws-access-key-id }} @@ -103,11 +115,11 @@ jobs: - name: Login to Amazon ECR id: login-ecr - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} uses: aws-actions/amazon-ecr-login@v1 - name: Publish storybook - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} env: ECR_HOST: ${{ steps.login-ecr.outputs.registry }} run: | @@ -123,7 +135,7 @@ jobs: [[ $ECR_HOST =~ ^([0-9]*) ]] && REGISTRY=${BASH_REMATCH[1]} if aws ecr describe-images --repository-name=odin.ngx-storybook --registry-id $REGISTRY --image-ids=imageTag=$TAG > /dev/null 2>&1; then - echo "$TAG already exists on remote... skipping..." + echo "::notice ::$TAG already exists on remote... skipping..." exit 0 fi @@ -132,17 +144,12 @@ jobs: TAG=$TAG docker-compose build TAG=$TAG docker-compose push - if ! ([ $GITHUB_REF_NAME = "master" ] || [[ $GITHUB_REF_NAME =~ ^([0-9].*)\.x$ ]]); then - echo "PUBLISHABLE=false" >> $GITHUB_ENV - echo "Non-publishable branch; finishing build..." - fi - - name: Logout of Amazon ECR - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} run: docker logout ${{ steps.login-ecr.outputs.registry }} - name: Deploy - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.publishable == 'true' }} + if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} run: | echo "git tag" PACKAGE_VERSION=$(node -p "require('./lerna.json').version") @@ -154,8 +161,8 @@ jobs: uses: actions/upload-artifact@v3 if: failure() with: - name: ${{ env.junit-report-name }} - path: ${{ env.junit-report-path }} + name: ${{ inputs.junit-report-name }} + path: ${{ inputs.junit-report-path }} retention-days: 2 - name: Store npm artifact From 2f68c2f1e2bd8234ef31543ab1203b2bb5dc9740 Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Thu, 17 Mar 2022 14:20:34 +0100 Subject: [PATCH 03/10] github token --- .github/workflows/frontend-build-and-publish-lib.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/frontend-build-and-publish-lib.yml b/.github/workflows/frontend-build-and-publish-lib.yml index 74ac9294..d0077a08 100644 --- a/.github/workflows/frontend-build-and-publish-lib.yml +++ b/.github/workflows/frontend-build-and-publish-lib.yml @@ -39,6 +39,8 @@ on: required: true aws-secret-access-key: required: true + github-token: + required: true jobs: build: name: Build and publish library @@ -99,7 +101,7 @@ jobs: with: tag: ${{ steps.lerna.outputs.tag }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.github-token }} - name: Inform if tag exists if: ${{ steps.tag.outputs.exists == 'true' }} From 51b0e20dc3dd96a9f627414bede23061bcb2deb3 Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Thu, 17 Mar 2022 15:35:24 +0100 Subject: [PATCH 04/10] remove storybook part --- .../frontend-build-and-publish-lib.yml | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/.github/workflows/frontend-build-and-publish-lib.yml b/.github/workflows/frontend-build-and-publish-lib.yml index d0077a08..00095417 100644 --- a/.github/workflows/frontend-build-and-publish-lib.yml +++ b/.github/workflows/frontend-build-and-publish-lib.yml @@ -27,18 +27,9 @@ on: required: false type: string default: test-results.xml - aws-region: - description: Which AWS region to use for publish storybook (defaults to eu-west-1) - required: false - type: string - default: eu-west-1 secrets: npm-token: required: true - aws-access-key-id: - required: true - aws-secret-access-key: - required: true github-token: required: true jobs: @@ -75,9 +66,6 @@ jobs: - name: Test run: npm run test -- --browsers=ChromeHeadlessCI --no-watch --no-progress - - name: Build storybook - run: npm run build:storybook - - name: Check if commit is publishable id: commit run: | @@ -107,49 +95,6 @@ jobs: if: ${{ steps.tag.outputs.exists == 'true' }} run: echo "::notice ::Tag already exists. Please make sure you bump version!" - - name: Configure AWS credentials - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.aws-access-key-id }} - aws-secret-access-key: ${{ secrets.aws-secret-access-key }} - aws-region: ${{ inputs.aws-region }} - - - name: Login to Amazon ECR - id: login-ecr - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} - uses: aws-actions/amazon-ecr-login@v1 - - - name: Publish storybook - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} - env: - ECR_HOST: ${{ steps.login-ecr.outputs.registry }} - run: | - TAG=$(node -p "require('./storybook/package.json').version") - if $GITHUB_REF_NAME == 'develop' - then - TAG=$TAG-dev-$GITHUB_RUN_ID - elif [[ $GITHUB_REF_NAME =~ ^feature\/(.*)$ ]] - then - TAG=$TAG-demo-${BASH_REMATCH[1]}-$GITHUB_RUN_ID - fi - - [[ $ECR_HOST =~ ^([0-9]*) ]] && REGISTRY=${BASH_REMATCH[1]} - - if aws ecr describe-images --repository-name=odin.ngx-storybook --registry-id $REGISTRY --image-ids=imageTag=$TAG > /dev/null 2>&1; then - echo "::notice ::$TAG already exists on remote... skipping..." - exit 0 - fi - - npm run build:storybook - - TAG=$TAG docker-compose build - TAG=$TAG docker-compose push - - - name: Logout of Amazon ECR - if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} - run: docker logout ${{ steps.login-ecr.outputs.registry }} - - name: Deploy if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} run: | From 68ee57f296b2ae54e891fef40f20ff7483a8519a Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Fri, 18 Mar 2022 11:44:45 +0100 Subject: [PATCH 05/10] add storybook support, change file name --- ...ml => frontend-build-and-publish-libs.yml} | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) rename .github/workflows/{frontend-build-and-publish-lib.yml => frontend-build-and-publish-libs.yml} (60%) diff --git a/.github/workflows/frontend-build-and-publish-lib.yml b/.github/workflows/frontend-build-and-publish-libs.yml similarity index 60% rename from .github/workflows/frontend-build-and-publish-lib.yml rename to .github/workflows/frontend-build-and-publish-libs.yml index 00095417..a86d9892 100644 --- a/.github/workflows/frontend-build-and-publish-lib.yml +++ b/.github/workflows/frontend-build-and-publish-libs.yml @@ -22,14 +22,28 @@ on: required: false type: string default: ./junit/ + has-storybook: + description: Whether storybook exists in project (defaults to false) + required: false + type: boolean + default: false junit-report-name: description: The file name for unit test report (defaults to test-results.xml) required: false type: string default: test-results.xml + aws-region: + description: Which AWS region to use for publish storybook (defaults to eu-west-1) + required: false + type: string + default: eu-west-1 secrets: npm-token: required: true + aws-access-key-id: + required: true + aws-secret-access-key: + required: true github-token: required: true jobs: @@ -66,6 +80,10 @@ jobs: - name: Test run: npm run test -- --browsers=ChromeHeadlessCI --no-watch --no-progress + - name: Build storybook + if: inputs.has-storybook + run: npm run build:storybook + - name: Check if commit is publishable id: commit run: | @@ -95,6 +113,47 @@ jobs: if: ${{ steps.tag.outputs.exists == 'true' }} run: echo "::notice ::Tag already exists. Please make sure you bump version!" + - name: Configure AWS credentials + if: ${{ inputs.has-storybook && steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.aws-access-key-id }} + aws-secret-access-key: ${{ secrets.aws-secret-access-key }} + aws-region: ${{ inputs.aws-region }} + + - name: Login to Amazon ECR + id: login-ecr + if: ${{ inputs.has-storybook && steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} + uses: aws-actions/amazon-ecr-login@v1 + + - name: Publish storybook + if: ${{ inputs.has-storybook && steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} + env: + ECR_HOST: ${{ steps.login-ecr.outputs.registry }} + run: | + TAG=$(node -p "require('./storybook/package.json').version") + if $GITHUB_REF_NAME == 'develop' + then + TAG=$TAG-dev-$GITHUB_RUN_ID + elif [[ $GITHUB_REF_NAME =~ ^feature\/(.*)$ ]] + then + TAG=$TAG-demo-${BASH_REMATCH[1]}-$GITHUB_RUN_ID + fi + + [[ $ECR_HOST =~ ^([0-9]*) ]] && REGISTRY=${BASH_REMATCH[1]} + + if aws ecr describe-images --repository-name=odin.ngx-storybook --registry-id $REGISTRY --image-ids=imageTag=$TAG > /dev/null 2>&1; then + echo "::notice ::$TAG already exists on remote... skipping..." + exit 0 + fi + + TAG=$TAG docker-compose build + TAG=$TAG docker-compose push + + - name: Logout of Amazon ECR + if: ${{ inputs.has-storybook && steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} + run: docker logout ${{ steps.login-ecr.outputs.registry }} + - name: Deploy if: ${{ steps.commit.outputs.publishable == 'true' && steps.tag.outputs.exists == 'false' }} run: | @@ -119,4 +178,3 @@ jobs: name: npm-logs path: ~/.npm/_logs/* retention-days: 2 - From 4eafdaa258e381bdb9a1e070f81f112d65cfa924 Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:20:21 +0100 Subject: [PATCH 06/10] add workflow for casino and cashier --- ...-build-and-publish-casinos-and-cashier.yml | 185 ++++++++++++++++++ .../frontend-build-and-publish-libs.yml | 10 +- 2 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/frontend-build-and-publish-casinos-and-cashier.yml diff --git a/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml b/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml new file mode 100644 index 00000000..90afc710 --- /dev/null +++ b/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml @@ -0,0 +1,185 @@ +name: Frontend Build and Publish Casino and Cashier +on: + workflow_call: + inputs: + node-version: + description: Node version to use (defaults to 14) + required: false + type: string + default: '14' + npm-registry-url: + description: The url address for npm registry (defaults to https://www.myget.org/F/river-tech/npm/) + required: false + type: string + default: https://www.myget.org/F/river-tech/npm/ + npm-registry-scope: + description: The name of the npm scope (defaults to @odin) + required: false + type: string + default: '@odin' + aws-region: + description: Which AWS region to use for publish storybook (defaults to eu-west-1) + required: false + type: string + default: eu-west-1 + secrets: + npm-token: + required: true + aws-access-key-id: + required: true + aws-secret-access-key: + required: true + github-token: + required: true +jobs: + build: + name: Build and publish + runs-on: ubuntu-latest + env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1" + DOTNET_CLI_TELEMETRY_OPTOUT: "1" + PUBLISH_PATH: obj/Docker/publish + ODIN_CI_DEBUG_MODE: "true" + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + always-auth: true + registry-url: ${{ inputs.npm-registry-url }} + scope: ${{ inputs.npm-registry-scope }} + + - name: Print environment versions + run: | + NODE_V=$(node --version) + NPM_V=$(npm -v) + echo node version':' $NODE_V + echo npm version':' $NPM_V + docker -v + docker-compose -v + DOTNET_CLI_V=$(dotnet --version) + echo dotnet cli version':' $DOTNET_CLI_V + git --version + + - name: Checkout + uses: actions/checkout@v3.0.0 + + - name: Install npm + run: npm ci + env: + NODE_AUTH_TOKEN: ${{ secrets.npm-token }} + + - name: Lint + run: npm run lint + + - name: Build + run: npm run build:rel + + - name: Install tools + run: npm i -g @odin/infra.ci@0.1.22 + env: + NODE_AUTH_TOKEN: ${{ secrets.npm-token }} + + - name: Dotnet restore/publish + run: | + SOLUTION=$(node -p "require('./package.json').vsBuildSolution") + dotnet restore $SOLUTION /p:Configuration=Release + dotnet publish $SOLUTION -c Release -o ./$PUBLISH_PATH + + - name: Set environment variables + run: | + PACKAGE_VERSION=$(node -p "require('./package.json').version") + echo "APP_NAME=$(node -p "require('./package.json').name")" >> $GITHUB_ENV + echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV + + if [[ "$GITHUB_REF_NAME" =~ ^feature\/(.*)$ ]] + then + echo "APP_VERSION=$PACKAGE_VERSION-demo-${BASH_REMATCH[1]}-$GITHUB_RUN_ID" >> $GITHUB_ENV + elif [[ "$GITHUB_REF_NAME" =~ ^hotfix\/(.*)$ ]] + then + echo "APP_VERSION=$PACKAGE_VERSION-hotfix-${BASH_REMATCH[1]}-$GITHUB_RUN_ID" >> $GITHUB_ENV + else + echo "APP_VERSION=$(ci get:app-version --packageVersion=$PACKAGE_VERSION --branch=$GITHUB_REF_NAME --incrementalSuffix=$GITHUB_RUN_ID)" >> $GITHUB_ENV + fi + + - name: Check if tag exists + uses: mukunku/tag-exists-action@v1.0.0 + id: tag + with: + tag: ${{ env.APP_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.github-token }} + + - name: Inform if tag exists + if: ${{ steps.tag.outputs.exists == 'true' }} + run: echo "::notice ::Tag already exists." + + - name: Configure AWS credentials + if: ${{ steps.tag.outputs.exists == 'false' }} + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.aws-access-key-id }} + aws-secret-access-key: ${{ secrets.aws-secret-access-key }} + aws-region: ${{ inputs.aws-region }} + + - name: Login to Amazon ECR + id: login-ecr + if: ${{ steps.tag.outputs.exists == 'false' }} + uses: aws-actions/amazon-ecr-login@v1 + + - name: Deploy + if: ${{ steps.tag.outputs.exists == 'false' }} + env: + ECR_HOST: ${{ steps.login-ecr.outputs.registry }} + run: | + docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ci.yml build + docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ci.yml push + + - name: Logout of Amazon ECR + if: ${{ steps.tag.outputs.exists == 'false' }} + run: docker logout ${{ steps.login-ecr.outputs.registry }} + + - name: Create Git tag for release + run: | + git tag $APP_VERSION + git push --tags + + - name: Downmerge master to develop + run: | + if [ "$GITHUB_REF_NAME" != "master" ] + then + echo "::notice ::Skipping downmerge. Branch is not master." + exit 0 + fi + + git fetch + git checkout develop + git config user.email "deploy-bot@riverigaming.com" + git config user.name "rig-autobot" + + if git merge --no-commit --no-ff --no-edit origin/master + then + if [ -z "$(git status --porcelain)" ] + then + echo "::notice ::Nothing to commit" + else + git commit --no-edit + git push origin develop + fi + else + if git merge HEAD + then + echo "::notice ::"Nothing to merge" + else + echo "::warning ::"Failed to downmerge. Conflicts between master and develop." + git merge --abort + fi + fi + + - name: Store npm artifact + uses: actions/upload-artifact@v3 + if: failure() + with: + name: npm-logs + path: ~/.npm/_logs/* + retention-days: 2 diff --git a/.github/workflows/frontend-build-and-publish-libs.yml b/.github/workflows/frontend-build-and-publish-libs.yml index a86d9892..492b163f 100644 --- a/.github/workflows/frontend-build-and-publish-libs.yml +++ b/.github/workflows/frontend-build-and-publish-libs.yml @@ -22,11 +22,6 @@ on: required: false type: string default: ./junit/ - has-storybook: - description: Whether storybook exists in project (defaults to false) - required: false - type: boolean - default: false junit-report-name: description: The file name for unit test report (defaults to test-results.xml) required: false @@ -37,6 +32,11 @@ on: required: false type: string default: eu-west-1 + has-storybook: + description: Whether storybook exists in project (defaults to false) + required: false + type: boolean + default: false secrets: npm-token: required: true From 11a21032040a4918cbb9965a89b2c82d9890cb04 Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Wed, 23 Mar 2022 09:29:27 +0100 Subject: [PATCH 07/10] workflow for configs --- .../frontend-build-and-tag-configs.yml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/frontend-build-and-tag-configs.yml diff --git a/.github/workflows/frontend-build-and-tag-configs.yml b/.github/workflows/frontend-build-and-tag-configs.yml new file mode 100644 index 00000000..dd5df1fd --- /dev/null +++ b/.github/workflows/frontend-build-and-tag-configs.yml @@ -0,0 +1,72 @@ +name: Frontend Build and Tag Configs +on: + workflow_call: + inputs: + aws-region: + description: Which AWS region to use for publish storybook (defaults to eu-west-1) + required: false + type: string + default: eu-west-1 + secrets: + aws-access-key-id: + required: true + aws-secret-access-key: + required: true +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.aws-access-key-id }} + aws-secret-access-key: ${{ secrets.aws-secret-access-key }} + aws-region: ${{ inputs.aws-region }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Checkout + uses: actions/checkout@v3.0.0 + + - name: Print environment versions + uses: mosteo-actions/docker-run@v1 + with: + image: ${{ steps.login-ecr.outputs.registry }}/deploy-ci:7.3.40 + command: ci deps + + - name: Lint JSON + uses: mosteo-actions/docker-run@v1 + with: + image: ${{ steps.login-ecr.outputs.registry }}/deploy-ci:7.3.40 + command: ci lint-json "./config/**/*.json" + + - name: Logout of Amazon ECR + run: docker logout ${{ steps.login-ecr.outputs.registry }} + + tag: + name: Tag + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3.0.0 + + - name: Check if branch is publishable + id: branch + run: | + if ! ([[ $GITHUB_REF_NAME =~ ^([0-9].*)\.x$ ]]); then + echo "::set-output name=publishable::false" + echo "::notice ::Non-publishable branch." + else + echo "::set-output name=publishable::true" + fi + + - name: Git Tag + if: ${{ steps.branch.outputs.publishable == 'true' }} + run: | + PACKAGE_VERSION=$(node -p "require('./package.json').version") + git tag $PACKAGE_VERSION + git push --tags From bbf3de1e81d39e2469f9901508536a15cc22986d Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Wed, 23 Mar 2022 12:05:59 +0100 Subject: [PATCH 08/10] update --- .../workflows/frontend-build-and-publish-casinos-and-cashier.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml b/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml index 90afc710..b13d7264 100644 --- a/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml +++ b/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml @@ -140,6 +140,7 @@ jobs: run: docker logout ${{ steps.login-ecr.outputs.registry }} - name: Create Git tag for release + if: ${{ steps.tag.outputs.exists == 'false' }} run: | git tag $APP_VERSION git push --tags From da3cb7ebd4674ad8ca06348f45f8f396787a092c Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Thu, 24 Mar 2022 07:55:06 +0100 Subject: [PATCH 09/10] change name --- ...inos-and-cashier.yml => frontend-build-and-publish-apps.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{frontend-build-and-publish-casinos-and-cashier.yml => frontend-build-and-publish-apps.yml} (99%) diff --git a/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml b/.github/workflows/frontend-build-and-publish-apps.yml similarity index 99% rename from .github/workflows/frontend-build-and-publish-casinos-and-cashier.yml rename to .github/workflows/frontend-build-and-publish-apps.yml index b13d7264..4de51ce8 100644 --- a/.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml +++ b/.github/workflows/frontend-build-and-publish-apps.yml @@ -1,4 +1,4 @@ -name: Frontend Build and Publish Casino and Cashier +name: Frontend Build and Publish Apps on: workflow_call: inputs: From 655e5e33abbfa9d76aab8aed586ab62af1b90414 Mon Sep 17 00:00:00 2001 From: tomaszbaron <91874431+tomaszbaron@users.noreply.github.com> Date: Thu, 24 Mar 2022 10:04:05 +0100 Subject: [PATCH 10/10] support dotnet version --- .github/workflows/frontend-build-and-publish-apps.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/frontend-build-and-publish-apps.yml b/.github/workflows/frontend-build-and-publish-apps.yml index 4de51ce8..0a2cdea2 100644 --- a/.github/workflows/frontend-build-and-publish-apps.yml +++ b/.github/workflows/frontend-build-and-publish-apps.yml @@ -22,6 +22,11 @@ on: required: false type: string default: eu-west-1 + dotnet-version: + description: dotnet version to use (defaults to 6.0.x) + required: false + type: string + default: '6.0.x' secrets: npm-token: required: true @@ -48,6 +53,11 @@ jobs: always-auth: true registry-url: ${{ inputs.npm-registry-url }} scope: ${{ inputs.npm-registry-scope }} + + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v2.0.0 + with: + dotnet-version: ${{ inputs.dotnet-version }} - name: Print environment versions run: |