Add prototype of create_new_RSPEC Github Action

This commit is contained in:
Nicolas Harraudeau 2020-09-24 13:11:57 +02:00
parent 9b280cefac
commit f196fce9fb
2 changed files with 44 additions and 0 deletions

26
.github/workflows/create_new_rspec.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Create New RSPEC
# Workflow runs when manually triggered using the UI or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
languages:
description: 'Comma-separated list of targeted languages'
required: true
jobs:
create_new_rule:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: true
ref: rspec-id-counter
path: 'rspec-id-counter'
- name: 'Increment the RSPEC ID counter'
working-directory: 'rspec-id-counter'
run: ./scripts/reserve_rspec_id.sh
- name: 'Test RSPEC ID'
run: echo $RSPEC_ID

18
scripts/reserve_rspec_id.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
# Script reserving a RSPEC identifier.
# It is used by the Github Action script "create_new_rspec.yml".
# Stop script in case of error.
set -e
# Increment the next_id counter.
next_id=`cat next_rspec_id.txt`
new_next_id=`expr $next_id + 1`
echo $new_next_id > next_rspec_id.txt
git add next_rspec_id.txt
git commit "Increment RSPEC ID counter"
git push origin rspec-id-counter
# Set the Environment variable for the next Github Action.
echo "::set-env name RSPEC_ID=${next_id}"