Skip to content

Commit

Permalink
ts->js
Browse files Browse the repository at this point in the history
  • Loading branch information
yurii-glia committed Oct 23, 2023
1 parent 60f9d5c commit 67291a2
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 8 deletions.
10 changes: 10 additions & 0 deletions .github/actions/deployment-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'Deployment validation'
description: 'Validates if deployment action can be run'
inputs:
branch-name:
description: 'The branch name should be validated'
required: true
default: ''
runs:
using: 'node20'
main: 'deployment-action.js'
16 changes: 16 additions & 0 deletions .github/actions/deployment-action/deployment-action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
var core = require("@actions/core");
var github = require("@actions/github");
try {
var ref = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a["head"]["ref"];
console.log(ref);
if (ref == 'master' || (ref === null || ref === void 0 ? void 0 : ref.startsWith('release')) == true) { }
else {
core.setFailed("'".concat(ref, "' branch can't be released. Only 'master' or 'release/*' branches can be released."));
}
}
catch (error) {
core.setFailed(error.message);
}
14 changes: 14 additions & 0 deletions .github/actions/deployment-action/deployment-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as core from '@actions/core';
import * as github from '@actions/github';

try {
const ref = github.context.payload.pull_request?.["head"]["ref"] as string | null | undefined;
console.log(ref);

if (ref == 'master' || ref?.startsWith('release') == true) {} else {
core.setFailed(`'${ref}' branch can't be released. Only 'master' or 'release/*' branches can be released.`);
core.setOutput(`'${ref}' branch can't be released. Only 'master' or 'release/*' branches can be released.`, 'forbidden');
}
} catch(error) {
core.setFailed(error.message);
}
237 changes: 237 additions & 0 deletions .github/actions/deployment-action/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .github/actions/deployment-action/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "deployment-action",
"version": "1.0.0",
"description": "",
"main": "deployment-action.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0"
}
}
22 changes: 14 additions & 8 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
name: Deployment

on:
workflow_dispatch:
inputs:
version:
description: 'Version in semantic versioning format (i.e. 1.0.2)'
required: true
pull_request
# workflow_dispatch:
# inputs:
# version:
# description: 'Version in semantic versioning format (i.e. 1.0.2)'
# required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Runs the deployment workflow in Bitrise
run: |
curl https://app.bitrise.io/app/${{ secrets.BITRISE_APP_ID }}/build/start.json --data '{"hook_info":{"type":"bitrise","build_trigger_token":"${{ secrets.BITRISE_BUILD_TRIGGER_TOKEN }}"},"build_params":{"branch":"master","workflow_id":"publish_to_nexus","environments":[{"mapped_to":"NEW_VERSION","value":"${{ github.event.inputs.version }}","is_expand":true}]},"triggered_by":"curl"}'
- name: Validate branch name before to start deployment
uses: ./.github/actions/deployment-action


# - uses: actions/checkout@v3
# - name: Runs the deployment workflow in Bitrise
# run: |
# curl https://app.bitrise.io/app/${{ secrets.BITRISE_APP_ID }}/build/start.json --data '{"hook_info":{"type":"bitrise","build_trigger_token":"${{ secrets.BITRISE_BUILD_TRIGGER_TOKEN }}"},"build_params":{"branch":"master","workflow_id":"publish_to_nexus","environments":[{"mapped_to":"NEW_VERSION","value":"${{ github.event.inputs.version }}","is_expand":true}]},"triggered_by":"curl"}'

0 comments on commit 67291a2

Please sign in to comment.