Skip to content

Commit

Permalink
add tag filter input
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyLadanov committed Apr 5, 2024
1 parent a9081af commit 1066a3b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 24 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

### Вход

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

### Выход

Expand All @@ -31,13 +32,14 @@
- name: Store beta build revision
id: store_revision
uses: aps-m/betabuild-log-action@v3
uses: aps-m/betabuild-log-action@v4
with:
repo_token: ${{ secrets.REPO_TOKEN }}
var_name: 'REV'
tag_name: '1.0.0-b6'
remove_request: false
size: 350
tag_filter: '-b'
- name: Check output
run: echo ${{ steps.store_revision.outputs.rev_is_changed }}
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ inputs:
required: true
default: false

tag_filter:
description: 'Filter for tag'
required: true
default: '-b'

# Define your outputs here.
outputs:
rev_is_changed:
Expand Down
25 changes: 17 additions & 8 deletions dist/index.js

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

14 changes: 13 additions & 1 deletion src/betabuild_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function HandleStore(
current_val: string,
version_val: string,
limit = 150,
remove_request: boolean = false
remove_request: boolean = false,
tag_filter: string = ''
): any {
let rev_changed = true

Expand Down Expand Up @@ -61,6 +62,13 @@ export function HandleStore(
}
}

if (
version_val === '' ||
(tag_filter !== '' && version_val.search(tag_filter) === -1)
) {
rev_changed = false
}

if (rev_changed && !remove_request) {
arr.push(version_val)

Expand All @@ -76,3 +84,7 @@ export function HandleStore(

return result
}

// console.log(
// HandleStore('1.0.0;1.2.3;1.3.4', '1.3.5-b8', 150, false, '-b').Value
// )
17 changes: 10 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export async function run(): Promise<void> {
const tag_name: string = core.getInput('tag_name')
const size: number = Number(core.getInput('size'))
const remove_request = core.getInput('remove_request')
const tag_filter = core.getInput('tag_filter')

const var_def_value = 'init_item'

Expand All @@ -30,7 +31,7 @@ export async function run(): Promise<void> {
let VariableValue = ''

await GetVariable(var_name, repo_token, repo_owner, repo_name).then(
result => {
(result: any) => {
// eslint-disable-next-line no-console
if (result != null) {
//console.log(result.data.value)
Expand All @@ -39,8 +40,9 @@ export async function run(): Promise<void> {
VariableValue = result.data.value
}
},
err => {
(err: any) => {
console.log('Variable is no exist')
console.log(err)
}
)

Expand All @@ -52,7 +54,7 @@ export async function run(): Promise<void> {
repo_owner,
repo_name
).then(
result => {
(result: any) => {
// eslint-disable-next-line no-console
if (result != null) {
//console.log(result.data.value)
Expand All @@ -63,7 +65,7 @@ export async function run(): Promise<void> {
VariableValue = var_def_value
}
},
err => {
(err: any) => {
console.log(`Error of create variable "${var_name}"`)
console.log(err)
core.setFailed(err)
Expand All @@ -75,7 +77,8 @@ export async function run(): Promise<void> {
VariableValue,
tag_name,
size,
remove_request.toLowerCase() === 'true'
remove_request.toLowerCase() === 'true',
tag_filter
)

if (StoreResult.Rev_is_changed) {
Expand All @@ -96,14 +99,14 @@ export async function run(): Promise<void> {
repo_owner,
repo_name
).then(
result => {
(result: any) => {
// eslint-disable-next-line no-console
if (result != null) {
//console.log(result.data.value)
console.log(`Variable "${var_name}" was updated succesfully!`)
}
},
err => {
(err: any) => {
console.log('Error of update variable')
console.log(err)
core.setFailed(err)
Expand Down

0 comments on commit 1066a3b

Please sign in to comment.