-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from tfso/feat/PAPI-1181/setup-action
Feat/papi 1181/setup action
- Loading branch information
Showing
2 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
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,93 @@ | ||
### Github workflow for local test and development | ||
### act -W .\.github\workflows\test.yml -v -s GITHUB_TOKEN=################## | ||
name: Test action-deployment | ||
|
||
on: push | ||
|
||
env: | ||
DEPLOYMENT_ENVIRONMENT: dev | ||
jobs: | ||
setupTest: | ||
outputs: | ||
version: ${{ steps.deploy.outputs.version }} | ||
services: ${{ steps.deploy.outputs.services }} | ||
prerelease: ${{ steps.deploy.outputs.prerelease }} | ||
environment: ${{ steps.deploy.outputs.environment }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
path: 'action-helper' | ||
|
||
- name: Checkout Github | ||
uses: actions/checkout@v2 | ||
|
||
- uses: ./setup | ||
name: deploy | ||
id: deploy | ||
with: | ||
githubref: refs/tags/v1.1.199-feat.9 | ||
environment: ${{ env.DEPLOYMENT_ENVIRONMENT }} | ||
services: | | ||
[ | ||
{ | ||
"name": "Tfso-Worker-ProfileRequest", | ||
"datadog": "/worker/i", | ||
"port": "", | ||
"http-endpoint": "", | ||
"env-prefix-remapper": "ENV_WORKER_" | ||
}, | ||
{ | ||
"name": "Tfso-Api-ProfileRequest", | ||
"datadog": "/api/i", | ||
"port": "5000", | ||
"http-endpoint": "profilerequest.api2.24sevenoffice.com", | ||
"env-prefix-remapper": "ENV_API_" | ||
} | ||
] | ||
- name: output | ||
run: | | ||
echo "Version: $version" | ||
echo "Prerelease: $prerelease" | ||
echo "Environment: $environment" | ||
echo "Services: $services" | ||
echo "Conclusion: $conclusions" | ||
env: | ||
version: ${{ steps.deploy.outputs.version }} | ||
services: ${{ steps.deploy.outputs.services }} | ||
prerelease: ${{ steps.deploy.outputs.prerelease }} | ||
environment: ${{ steps.deploy.outputs.environment }} | ||
|
||
setupChecks: | ||
runs-on: ubuntu-latest | ||
needs: [setupTest] | ||
steps: | ||
- id: versioncheck | ||
name: Version Check | ||
if: ${{ (needs.setupTest.outputs.version != '1.1.199-feat.9') }} | ||
run: | | ||
echo "Version is not correct ${{ needs.setupTest.outputs.version }}" | ||
exit 1 | ||
- id: servicescheck | ||
name: Services Check | ||
if: ${{ (contains(needs.setupTest.outputs.services, 'Tfso-Api-ProfileRequest') != true) }} | ||
run: | | ||
echo "Services is not correct ${{ needs.setupTest.outputs.services }}" | ||
exit 1 | ||
- id: environmentcheck | ||
name: Environment Check | ||
if: ${{ needs.setupTest.outputs.environment != 'dev' }} | ||
run: | | ||
echo "Environment is not correct ${{ needs.setupTest.outputs.environment }}" | ||
exit 1 | ||
- id: prereleasecheck | ||
name: Prerelease Check | ||
if: ${{ needs.setupTest.outputs.prerelease != 'feat.9' }} | ||
run: | | ||
echo "Prerelease is not correct ${{ needs.setupTest.outputs.prerelease }}" | ||
exit 1 |
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,83 @@ | ||
name: 'Setup' | ||
description: '' | ||
|
||
inputs: | ||
environment: | ||
description: Environment | ||
required: false | ||
|
||
services: | ||
description: Services, initServices defaults to env.SERVICE_NAME | ||
required: false | ||
|
||
githubref: | ||
description: Github reference | ||
default: ${{ github.ref }} | ||
required: false | ||
|
||
regex: | ||
description: Semver regex | ||
default: 'refs\/tags\/v(.*)$' | ||
required: false | ||
|
||
outputs: | ||
version: | ||
description: the full version not including 'v', will be prereleased if build is a branch | ||
value: ${{ steps.semver.outputs.fullversion }} | ||
prerelease: | ||
description: prerelease suffix for PR builds and will truncate branchname to first word ('feature/my-feature' will be 'feature') unless TRUNCATE_PRERELEASE is set to `false` | ||
value: ${{ steps.semver.outputs.prerelease }} | ||
environment: | ||
description: environment | ||
value: ${{ steps.initEnvironment.outputs.result }} | ||
services: | ||
description: services | ||
value: ${{ steps.script.outputs.result }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: initialize default inputs (environment) | ||
id: initEnvironment | ||
uses: actions/github-script@v6 | ||
with: | ||
result-encoding: string | ||
script: | | ||
return process.env.environment || process.env.DEPLOYMENT_ENVIRONMENT; | ||
env: | ||
environment: ${{ inputs.environment }} | ||
|
||
- name: extract tag version | ||
id: semver | ||
uses: booxmedialtd/[email protected] | ||
with: | ||
input_string: ${{ inputs.githubref }} | ||
version_extractor_regex: ${{ inputs.regex }} | ||
|
||
- name: extract services | ||
uses: actions/github-script@v6 | ||
id: script | ||
with: | ||
result-encoding: string | ||
script: | | ||
var service = process.env.services || process.env.SERVICE_NAME; | ||
if(/^\s*[\[{][\s\S]*[\]}]\s*$/.test(service)) { | ||
return JSON.stringify([].concat(...[JSON.parse(service)])) | ||
} | ||
else { | ||
return JSON.stringify( | ||
String(service) | ||
.split(/[\n]/i) | ||
.filter(line => line.length > 0) | ||
.map(line => ( | ||
/(\w+=([^;]+);)+(\w+=([^;]+))?/g.test(line) == false | ||
? ({ name: line }) | ||
: Object.fromEntries(line | ||
.split(/;/g) | ||
.map(keyvaluepair => (/(\w+)=(.*)/g.exec(keyvaluepair) ?? []).splice(1)) | ||
) | ||
)) | ||
) | ||
} | ||
env: | ||
services: ${{ inputs.services }} |