diff --git a/.github/workflows/create_new_rspec.yml b/.github/workflows/create_new_rspec.yml new file mode 100644 index 0000000000..3af53273ab --- /dev/null +++ b/.github/workflows/create_new_rspec.yml @@ -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 diff --git a/scripts/reserve_rspec_id.sh b/scripts/reserve_rspec_id.sh new file mode 100755 index 0000000000..f2bc54fcd8 --- /dev/null +++ b/scripts/reserve_rspec_id.sh @@ -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}"