Add shared parts to the production firm #18
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: add-shared-parts-production | |
| run-name: Add shared parts to the production firm | |
| # We run this action when a "add-shared-parts-production-firm" label is added to the PR | |
| on: | |
| pull_request: | |
| types: | |
| - labeled | |
| - synchronize | |
| jobs: | |
| check-add-shared-parts-production-label: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_add_shared_parts_production_label: ${{ steps.haslabel.outputs.labeled-add-shared-parts-production-firm }} | |
| steps: | |
| - name: Checkout Repository - Fetch all history for all tags and branches | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Labeled to add shared parts | |
| id: haslabel | |
| uses: DanielTamkin/HasLabel@v1.0.4 | |
| with: | |
| contains: "add-shared-parts-production-firm" | |
| add-shared-parts-production: | |
| needs: check-add-shared-parts-production-label | |
| if: needs.check-add-shared-parts-production-label.outputs.has_add_shared_parts_production_label | |
| runs-on: ubuntu-latest | |
| env: | |
| SF_API_CLIENT_ID: "${{ secrets.SF_API_CLIENT_ID }}" | |
| SF_API_SECRET: "${{ secrets.SF_API_SECRET }}" | |
| steps: | |
| - name: Checkout Repository - Fetch all history for all tags and branches | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node v18 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| - name: Add silverfin-cli package latest version | |
| run: | | |
| npm install https://github.com/silverfin/silverfin-cli.git | |
| VERSION=$(./node_modules/silverfin-cli/bin/cli.js -V) | |
| echo "CLI version: ${VERSION}" | |
| - name: Create Silverfin config file | |
| run: | | |
| mkdir -p $HOME/.silverfin/ | |
| touch $HOME/.silverfin/config.json | |
| echo '${{ secrets.CONFIG_JSON }}' > $HOME/.silverfin/config.json | |
| node ./node_modules/silverfin-cli/bin/cli.js config --set-firm="${{ vars.FIRM_ID_PRODUCTION }}" | |
| node ./node_modules/silverfin-cli/bin/cli.js config --get-firm | |
| - name: Add shared parts | |
| run: | | |
| node ./node_modules/silverfin-cli/bin/cli.js add-shared-part --all --yes | |
| - name: Remove all labels | |
| uses: rogerluan/label-remover@v1.0.1 | |
| with: | |
| github_token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
| - name: Add Comment to PR | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: 'All Shared parts were added succesfully to the "Production firm"' | |
| }) | |
| - name: Prepare CONFIG_JSON for secret | |
| if: always() | |
| run: | | |
| CONFIG_JSON=$(cat $HOME/.silverfin/config.json | tr -d '\n') | |
| echo "CONFIG_JSON=${CONFIG_JSON}" >> $GITHUB_ENV | |
| - name: Store CONFIG_JSON as secret | |
| uses: gliech/create-github-secret-action@v1 | |
| if: always() | |
| with: | |
| name: CONFIG_JSON | |
| value: "${{ env.CONFIG_JSON }}" | |
| pa_token: ${{ secrets.REPO_ACCESS_TOKEN }} |