Merge pull request #264 from LedgerHQ/feature/sdk-generation
Automatic generation of the plugin SDK
This commit is contained in:
67
.github/actions/commit-changes/action.yml
vendored
Normal file
67
.github/actions/commit-changes/action.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
name: 'Commit and push if the version file has changed'
|
||||
|
||||
inputs:
|
||||
name:
|
||||
description: 'The name of the commiter'
|
||||
required: true
|
||||
default: 'github-actions[bot]'
|
||||
email:
|
||||
description: 'The email of the commiter'
|
||||
required: true
|
||||
default: 'github-actions[bot]@users.noreply.github.com'
|
||||
message:
|
||||
description: 'The commit message'
|
||||
required: true
|
||||
default: 'New release version(s)'
|
||||
files:
|
||||
description: 'The file(s) to add in the commit'
|
||||
required: true
|
||||
default: '*'
|
||||
directory:
|
||||
description: 'The directory in which the action will be performed'
|
||||
required: true
|
||||
default: '.'
|
||||
branch:
|
||||
description: 'Checkout (or create) on a specific branch before commit/push'
|
||||
required: true
|
||||
default: 'master'
|
||||
secret:
|
||||
description: 'A token allowing to push the commit on the repository'
|
||||
required: true
|
||||
default: '.'
|
||||
repository:
|
||||
description: 'The repository where to push'
|
||||
required: true
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Commit the changes
|
||||
run: |
|
||||
git config --global user.name ${{ inputs.name }}
|
||||
ORIGIN="$(pwd)"
|
||||
cd ${{ inputs.directory }}
|
||||
git switch ${{ inputs.branch }} 2>/dev/null || git switch -c ${{ inputs.branch }}
|
||||
git status
|
||||
CHANGES="$(git status --porcelain ${{ inputs.files }})"
|
||||
if [ -z "${CHANGES}" ]; \
|
||||
then \
|
||||
echo "No changes, stopping now"; \
|
||||
cd ${origin} \
|
||||
exit 0; \
|
||||
fi
|
||||
echo -e "Changes:\n${CHANGES}"
|
||||
git add ${{ inputs.files }}
|
||||
git commit -am "${{ inputs.message }}"
|
||||
git log -n 2
|
||||
cd ${ORIGIN}
|
||||
shell: bash
|
||||
|
||||
- name: Push commit
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ inputs.secret }}
|
||||
branch: ${{ inputs.branch }}
|
||||
directory: ${{ inputs.directory }}
|
||||
repository: ${{ inputs.repository }}
|
||||
43
.github/workflows/sdk-generation.yml
vendored
Normal file
43
.github/workflows/sdk-generation.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
name: Updating the SDK
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
updating_SDK:
|
||||
name: Updating the SDK
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Clone
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# by default the action uses fetch-depth = 1, which creates
|
||||
# shallow repositories from which we can't push
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
# needed, else the push inside the action will use default credentials
|
||||
# instead of provided ones
|
||||
persist-credentials: false
|
||||
|
||||
- name: Build new SDK
|
||||
run: python tools/build_sdk.py
|
||||
|
||||
- name: Extract branch name
|
||||
shell: bash
|
||||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
||||
id: extract_branch
|
||||
|
||||
- name: Commit & push changes in the SDK if any
|
||||
uses: ./.github/actions/commit-changes
|
||||
with:
|
||||
name: 'ldg-github-ci'
|
||||
directory: ethereum-plugin-sdk
|
||||
branch: ${{ steps.extract_branch.outputs.branch }}
|
||||
message: "[update] Branch ${{ steps.extract_branch.outputs.branch }} | Commit ${GITHUB_SHA}"
|
||||
secret: ${{ secrets.CI_BOT_TOKEN }}
|
||||
repository: LedgerHQ/ethereum-plugin-sdk
|
||||
Reference in New Issue
Block a user