Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e5cd5f9
Printing labels from pull request
MostefaKamalLala Aug 13, 2021
0bd62c5
Added important inputs
MostefaKamalLala Aug 13, 2021
12fd923
Added github token input
MostefaKamalLala Aug 13, 2021
e51b9c0
Fixed auth
MostefaKamalLala Aug 13, 2021
c69ecb7
Added new wait to connect
MostefaKamalLala Aug 16, 2021
eb74dc2
Changed npm packages
MostefaKamalLala Aug 16, 2021
8bf3774
Changed code
MostefaKamalLala Aug 17, 2021
11c4ce0
Fixed get input
MostefaKamalLala Aug 17, 2021
df5fe38
Revert "Fixed get input"
MostefaKamalLala Aug 17, 2021
a5180d3
Revert "Changed code"
MostefaKamalLala Aug 17, 2021
3e708de
Revert "Changed npm packages"
MostefaKamalLala Aug 16, 2021
aba360d
Revert "Added new wait to connect"
MostefaKamalLala Aug 16, 2021
8aa1fc4
Fixed input
MostefaKamalLala Aug 17, 2021
86e6346
Added new wait to connect
MostefaKamalLala Aug 17, 2021
520f8c4
Fixed new api auth
MostefaKamalLala Aug 16, 2021
44157c9
Fixed printing
MostefaKamalLala Aug 17, 2021
9f044c9
Printing names only
MostefaKamalLala Aug 18, 2021
ccedc70
Merging versions by service and sorting highest
MostefaKamalLala Aug 19, 2021
4747bc8
Getting latest tag with graphQl
MostefaKamalLala Aug 24, 2021
5ec8fcc
Changed graphQl usage
MostefaKamalLala Aug 24, 2021
491acaa
More logging
MostefaKamalLala Aug 24, 2021
a86b05a
Changed set output location
MostefaKamalLala Aug 24, 2021
dd1b6fa
Added semver bumper
MostefaKamalLala Aug 24, 2021
31922a8
Added chart and .net core files version
MostefaKamalLala Aug 26, 2021
2968321
Fixed printing context for debug
MostefaKamalLala Aug 26, 2021
6e0a225
Listing service metadata versioning files paths
MostefaKamalLala Aug 27, 2021
d075998
Fixed return error
MostefaKamalLala Aug 27, 2021
185fe99
Changed file unexistant error catching
MostefaKamalLala Aug 27, 2021
e040057
Hopefully last fixed of the error
MostefaKamalLala Aug 27, 2021
38cdda0
Changed async methods and improved logging
MostefaKamalLala Aug 27, 2021
dbff1dc
Fixed error handling
MostefaKamalLala Aug 27, 2021
12b557a
Added error hint
MostefaKamalLala Aug 27, 2021
b52bd6e
More debugging
MostefaKamalLala Aug 27, 2021
b7cbd62
Fixed logic
MostefaKamalLala Aug 27, 2021
beaba7b
Fixed custom service path bug
MostefaKamalLala Aug 27, 2021
de20968
More console debugging
MostefaKamalLala Aug 27, 2021
40c1ae7
Fixed split character for custom paths
MostefaKamalLala Aug 27, 2021
7c9580a
Edit files, push tag, create release
MostefaKamalLala Aug 31, 2021
236f845
Fixed enum
MostefaKamalLala Aug 31, 2021
655014a
Fixes
MostefaKamalLala Aug 31, 2021
4858116
Fixed create tag and release without version files
MostefaKamalLala Aug 31, 2021
2e98838
Error handling
MostefaKamalLala Sep 1, 2021
3397b68
Debugged error handling
MostefaKamalLala Sep 1, 2021
5230102
More debug printing
MostefaKamalLala Sep 1, 2021
78e7dc8
Debug
MostefaKamalLala Sep 1, 2021
164eb9f
More logging
MostefaKamalLala Sep 1, 2021
5112b22
More debug messages
MostefaKamalLala Sep 1, 2021
4e7794d
More errors handling
MostefaKamalLala Sep 1, 2021
f8365ae
Git error handling
MostefaKamalLala Sep 1, 2021
9b10ade
Throwing error
MostefaKamalLala Sep 1, 2021
5f24661
Error handling
MostefaKamalLala Sep 1, 2021
5fb9f18
Error handling
MostefaKamalLala Sep 1, 2021
8f2d13c
Error handling
MostefaKamalLala Sep 1, 2021
87e6e18
Error handling
MostefaKamalLala Sep 1, 2021
cdd2d79
More error handling
MostefaKamalLala Sep 1, 2021
b0859c7
throw package
MostefaKamalLala Sep 1, 2021
e04e196
Error catch issue
MostefaKamalLala Sep 1, 2021
2353ccb
testing
MostefaKamalLala Sep 1, 2021
9e155b9
Removed trycatch
MostefaKamalLala Sep 1, 2021
d9b343f
error handling
MostefaKamalLala Sep 1, 2021
da2f30d
Debug error handling
MostefaKamalLala Sep 1, 2021
d01b766
Debug error handling
MostefaKamalLala Sep 1, 2021
ea207d8
Fixed error handling
MostefaKamalLala Sep 1, 2021
ecf0c4a
Added documentation
MostefaKamalLala Sep 2, 2021
d8a217a
Commented out tests temporarly
MostefaKamalLala Sep 2, 2021
f6ebb5d
Added workflow dispatch parameters
MostefaKamalLala Sep 2, 2021
4f85178
Fixed unique service path + doc
MostefaKamalLala Sep 2, 2021
3e1f12c
Fixed unique service path
MostefaKamalLala Sep 2, 2021
fbcfc0b
Updated documentation
MostefaKamalLala Sep 2, 2021
c6a7451
Updated documentation
MostefaKamalLala Sep 2, 2021
2b90313
Fixed documentation
MostefaKamalLala Sep 2, 2021
4248a16
Fixed outputs and unexistant service
MostefaKamalLala Sep 2, 2021
a00afc2
Bonified output
MostefaKamalLala Sep 2, 2021
b8dceec
Fixed error handling messages
MostefaKamalLala Sep 2, 2021
0786e8e
Fixed printing
MostefaKamalLala Sep 2, 2021
51ae70c
Testing something new
MostefaKamalLala Sep 2, 2021
d7c5ef3
Fixed error handling
MostefaKamalLala Sep 2, 2021
75e89ac
Testing output
MostefaKamalLala Sep 2, 2021
e6a48b0
Fixed output
MostefaKamalLala Sep 3, 2021
a5d885a
Added generated code pre-commit support
MostefaKamalLala Sep 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 91 additions & 51 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,94 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"excludedFiles": ["*.stories.ts"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "scope:app",
"onlyDependOnLibsWithTags": ["*"]
},
{
"sourceTag": "scope:core",
"onlyDependOnLibsWithTags": ["scope:core", "scope:testing"]
},
{
"sourceTag": "scope:shared",
"onlyDependOnLibsWithTags": [
"scope:core",
"scope:shared",
"scope:legacy",
"scope:testing",
"scope:maps",
"scope:quotes"
]
},
{
"sourceTag": "scope:maps",
"onlyDependOnLibsWithTags": ["scope:core", "scope:shared", "scope:legacy", "scope:testing"]
},
{
"sourceTag": "scope:quotes",
"onlyDependOnLibsWithTags": [
"scope:core",
"scope:shared",
"scope:legacy",
"scope:quotes",
"scope:maps",
"scope:testing"
]
},
{
"sourceTag": "scope:aeon",
"onlyDependOnLibsWithTags": ["scope:core", "scope:shared", "scope:legacy", "scope:aeon"]
},
{
"sourceTag": "scope:legacy",
"onlyDependOnLibsWithTags": ["scope:legacy", "scope:core"]
},
{
"sourceTag": "scope:configs-client",
"onlyDependOnLibsWithTags": [
"scope:configs-client",
"scope:core",
"scope:configs",
"scope:shared",
"scope:legacy",
"scope:testing"
]
},
{
"sourceTag": "scope:configs",
"onlyDependOnLibsWithTags": [
"scope:configs",
"scope:core",
"scope:legacy",
"scope:shared",
"scope:testing"
]
}
]
}
]
}
},
"rules": {
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
{
"files": ["*.ts"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-this-alias": "off"
}
}
}
]
}
11 changes: 4 additions & 7 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"printWidth": 120,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
"useTabs": false,
"arrowParens": "avoid",
"endOfLine": "crlf"
}
214 changes: 113 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,104 +2,116 @@
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
</p>

# Create a JavaScript Action using TypeScript

Use this template to bootstrap the creation of a TypeScript action.:rocket:

This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.

If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)

## Create an action from this template

Click the `Use this Template` and provide the new repo details for your action

## Code in Main

> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.

Install the dependencies
```bash
$ npm install
```

Build the typescript and package it for distribution
```bash
$ npm run build && npm run package
```

Run the tests :heavy_check_mark:
```bash
$ npm test

PASS ./index.test.js
✓ throws invalid number (3ms)
✓ wait 500 ms (504ms)
✓ test runs (95ms)

...
```

## Change action.yml

The action.yml contains defines the inputs and output for your action.

Update the action.yml with your name, description, inputs and outputs for your action.

See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)

## Change the Code

Most toolkit and CI/CD operations involve async operations so the action is run in an async function.

```javascript
import * as core from '@actions/core';
...

async function run() {
try {
...
}
catch (error) {
core.setFailed(error.message);
}
}

run()
```

See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.

## Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run [ncc](https://github.com/zeit/ncc) and push the results:
```bash
$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
```

Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project.

Your action is now published! :rocket:

See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)

## Validate

You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))

```yaml
uses: ./
with:
milliseconds: 1000
```

See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:

## Usage:

After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action
# Microservices version auto bumping

This action helps to automatically bump version files, create tag and a release when a closed pull-request with specific labels containing the service name and the release type is found.
The list of files that contain the version that need to be changed will updated in the future depending on usage requirement. At the moment, version files of Helm charts and .Net core projects are supported.
However it is not necessary to change files to tag and create a release.

More paramaters and outputs will be added in the future.

## Usage

This example workflow contains a condition on job level as said before for the workflow to run.
In order to avoid multiple useless versions bumping a guard exist to run the workflow only once with the same context.
if an issue occurs, warning will be added to the run summary.

It is important to checkout the master/main branch before and set the git config.

For a manual run, providing service_name and release_type parameter is necessary.

```YAML
name: Version Bumping

on:
workflow_dispatch:
inputs:
release_type:
description: "Major, Minor or Patch"
required: true
service:
description: "Service name"
required: true
service_path:
description: "The service path"
required: true
pull_request:
types:
- closed

jobs:
setup:
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.merged == true &&
(contains(toJson(github.event.pull_request.labels.*.name), ':patch') ||
contains(toJson(github.event.pull_request.labels.*.name), ':minor') ||
contains(toJson(github.event.pull_request.labels.*.name), ':major')))
concurrency: version-bumping
steps:
- name: Setting variables
if: github.event_name != 'workflow_dispatch'
run: |
echo "UNIQUE_FILE_NAME=${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
echo "CACHE_PATH=${{ github.workspace }}/firstrun" >> $GITHUB_ENV

- name: Cache workflow run
if: github.event_name != 'workflow_dispatch'
id: cache-workflow-run
uses: actions/cache@v2
env:
cache-name: ${{ env.UNIQUE_FILE_NAME }}
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-${{ env.cache-name }}

- name: "Checkout"
if: steps.cache-workflow-run.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
ref: master
- run: |
git config --global user.email "${{ secrets.AUTO_BUMP_MAIL }}"
git config --global user.name "${{ secrets.AUTO_BUMP_NAME }}"

- name: Autobumping
if: steps.cache-workflow-run.outputs.cache-hit != 'true' && github.event_name != 'workflow_dispatch'
uses: cactusoft-ca/microservices-versioning@main
id: microservices_versioning
with:
pull_number: ${{ github.event.number }}
owner: cactusoft-ca
repo: microservices-versioning
token: ${{ secrets.GITHUB_TOKEN }}
working_directory: ${{ github.workspace }}
services_path: "services"
custom_services_path: |
service2,custom/service2/path

- name: Manual autobumping
if: steps.cache-workflow-run.outputs.cache-hit != 'true' && github.event_name == 'workflow_dispatch'
uses: cactusoft-ca/microservices-versioning@main
with:
pull_number: ${{ github.event.number }}
owner: cactusoft-ca
repo: microservices-versioning
token: ${{ secrets.GITHUB_TOKEN }}
working_directory: ${{ github.workspace }}
service_name: ${{ github.event.inputs.service_name }}
# release type: Patch, minor or major
release_type: ${{ github.event.inputs.release_type }}
# service_path ex: direct/path/to/services2
service_path: ${{ github.event.inputs.service_path }}

# results is empty atm
- name: Saving first run results
if: github.event_name != 'workflow_dispatch' && steps.cache-workflow-run.outputs.cache-hit == 'true'
run: |
echo "${{ steps.microservices_versioning.outputs.results }}" > ${{ env.CACHE_PATH }}

- name: Workflow already triggered
if: github.event_name != 'workflow_dispatch' && steps.cache-workflow-run.outputs.cache-hit == 'true'
run: |
echo "Already runned" > ${{ env.CACHE_PATH }}
```
Loading