-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(ci): change from circle ci to github actions #8
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e4b9133
chore(ci): change from circle ci to github actions
tomaszbaron 95d9b52
fix comments
tomaszbaron 2f68c2f
github token
tomaszbaron 51b0e20
remove storybook part
tomaszbaron 68ee57f
add storybook support, change file name
tomaszbaron 4eafdaa
add workflow for casino and cashier
tomaszbaron 11a2103
workflow for configs
tomaszbaron bbf3de1
update
tomaszbaron da3cb7e
change name
tomaszbaron 655e5e3
support dotnet version
tomaszbaron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
186 changes: 186 additions & 0 deletions
186
.github/workflows/frontend-build-and-publish-casinos-and-cashier.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
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/[email protected] | ||
|
||
- 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/[email protected] | ||
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/[email protected] | ||
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 | ||
if: ${{ steps.tag.outputs.exists == 'false' }} | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part wasn't tested |
||
git checkout develop | ||
git config user.email "[email protected]" | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
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' | ||
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 | ||
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 | ||
has-storybook: | ||
description: Whether storybook exists in project (defaults to false) | ||
required: false | ||
type: boolean | ||
default: false | ||
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 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: ${{ 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 | ||
|
||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
||
- 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 | ||
if: inputs.has-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 "::notice ::This update doesn't need to be published." | ||
else | ||
echo "::set-output name=publishable::true" | ||
fi | ||
|
||
- name: Fetch tag from lerna | ||
id: lerna | ||
if: ${{ steps.commit.outputs.publishable == 'true' }} | ||
run: | | ||
TAG=$(node -p "require('./lerna.json').version") | ||
echo "::set-output name=tag::${TAG}" | ||
|
||
- name: Check if tag exists | ||
uses: mukunku/[email protected] | ||
id: tag | ||
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: ${{ 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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested, the docker image is created, but I wasn't able to check if the storybook is accessible |
||
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: | | ||
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: ${{ inputs.junit-report-name }} | ||
path: ${{ inputs.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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be apps, can we try with bo too please? as they have the same configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the file name and also added workflows to
odin.asgard.client.config
andodin.asgard.client
https://github.com/River-iGaming/odin.asgard.client.config/pull/16
https://github.com/River-iGaming/odin.asgard.client/pull/741
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vanir.config
has also the same Circle CI config but I don't have writhe right to the repo