Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyLadanov committed Mar 26, 2024
1 parent 25323fd commit 3c42c08
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 39 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

### Вход

| Параметр | Описание | Тип | Обязательный | Значение по умолчанию |
| ---------- | --------------------------------------- | ------ | ------------ | --------------------- |
| repo_token | Токен доступа к репозиторию | Строка | Да | - |
| var_name | Имя переменной для ведения журнала | Строка | Да | REV |
| tag_name | Значение версии для добавления в журнал | Строка | Да | - |
| size | Максимальный размер массива журнала | Число | Да | 350 |
| Параметр | Описание | Тип | Обязательный | Значение по умолчанию |
| -------------- | --------------------------------------- | ------ | ------------ | --------------------- |
| repo_token | Токен доступа к репозиторию | Строка | Да | - |
| var_name | Имя переменной для ведения журнала | Строка | Да | REV |
| tag_name | Значение версии для добавления в журнал | Строка | Да | - |
| size | Максимальный размер массива журнала | Число | Да | 350 |
| need_to_update | Флаг необходимости обновления журнала | Число | Да | true |

### Выход

Expand All @@ -30,11 +31,12 @@
- name: Store beta build revision
id: store_revision
uses: aps-m/betabuild-log-action@v1
uses: aps-m/betabuild-log-action@v2
with:
repo_token: ${{ secrets.REPO_TOKEN }}
var_name: 'REV'
tag_name: '1.0.0-b6'
need_to_update: true
size: 350
- name: Check output
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ inputs:
required: true
default: 350

need_to_update:
description: 'Need to update revisiob journal'
required: true
default: true

# Define your outputs here.
outputs:
rev_is_changed:
Expand Down
28 changes: 16 additions & 12 deletions dist/index.js

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

47 changes: 27 additions & 20 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export async function run(): Promise<void> {
const var_name: string = core.getInput('var_name')
const tag_name: string = core.getInput('tag_name')
const size: number = Number(core.getInput('size'))
const need_to_update = core.getInput('need_to_update')

const var_def_value = 'init_item'

const repo_owner = github.context.payload.repository?.owner.login
Expand Down Expand Up @@ -72,27 +74,32 @@ export async function run(): Promise<void> {
StoreResult = HandleStore(VariableValue, tag_name, size)

if (StoreResult.Rev_is_changed) {
console.log('New revision was detected, starting variable updating...')
await UpdateVariable(
StoreResult.Value,
var_name,
repo_token,
repo_owner,
repo_name
).then(
result => {
// eslint-disable-next-line no-console
if (result != null) {
//console.log(result.data.value)
console.log(`Variable "${var_name}" was updated succesfully!`)
}
},
err => {
console.log('Error of update variable')
console.log(err)
core.setFailed(err)
}
console.log(
`New revision was detected, flag need_to_update = ${need_to_update}`
)
if (need_to_update.toLowerCase() === 'true') {
console.log('Starting variable updating...')
await UpdateVariable(
StoreResult.Value,
var_name,
repo_token,
repo_owner,
repo_name
).then(
result => {
// eslint-disable-next-line no-console
if (result != null) {
//console.log(result.data.value)
console.log(`Variable "${var_name}" was updated succesfully!`)
}
},
err => {
console.log('Error of update variable')
console.log(err)
core.setFailed(err)
}
)
}
} else {
console.log('Defined version already exist in revision array')
}
Expand Down

0 comments on commit 3c42c08

Please sign in to comment.