|
# GitHub Actions Workflow: Yarn and Pod Installation (Example of Reusing a Flow) |
|
# |
|
# Summary: |
|
# This workflow prepares the environment for any main workflows by executing setup tasks: |
|
# 1. Generates a .env.personal file with configurations for a private npm registry (https://github.com/samitha9125/private-npm-setup) |
|
# 2. Sets up the private npm registry. |
|
# 3. Installs all project dependencies using yarn. |
|
# |
|
# Triggers: |
|
# - Invoked by other workflows via the `workflow_call` event. It requires a 'runner' input to specify the runner to be used. |
|
# |
|
# Jobs: |
|
# - yarn-setup: Performs three main steps as outlined in the Summary section. |
|
# - pod-install: A separate job to handle Pod installations. |
|
# |
|
# Environment: |
|
# - Utilizes environment variables for npm registry setup, fetched securely from GitHub secrets. |
|
# - Executes on a self-hosted runner as specified by the 'runner' input parameter. |
|
# |
|
# Notes: |
|
# In this example, a Private NPM Registery has been used. In your case, you may not need to do that. |
|
# |
|
|
|
name: Yarn Setup and Execution |
|
|
|
on: |
|
workflow_call: # https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow |
|
inputs: |
|
runner: |
|
description: 'The name of the runner to use.' |
|
required: true |
|
type: string |
|
|
|
jobs: |
|
yarn-setup: |
|
name: Yarn Setup |
|
runs-on: ['self-hosted', '${{ inputs.runner }}'] |
|
env: |
|
USERNAME: ${{ secrets.USERNAME }} |
|
PERSONAL_ACCESS_TOKEN: ${{ secrets.PASSWORD }} |
|
PRIVATE_REGISTRY_URL: 'https://npm.example.com' # Real URL of the registry. |
|
SCOPE: 'scope' # Scope of the package. here, "scope" has been used as an example. |
|
steps: |
|
- name: Checkout repository |
|
uses: actions/checkout@v2 |
|
- name: Generate .env.personal file |
|
run: | |
|
echo "USERNAME=${{ env.USERNAME }}" > .env.personal |
|
echo "PERSONAL_ACCESS_TOKEN=${{ env.PERSONAL_ACCESS_TOKEN }}" >> .env.personal |
|
echo "PRIVATE_REGISTRY_URL=${{ env.PRIVATE_REGISTRY_URL }}" >> .env.personal |
|
echo "SCOPE=${{ env.SCOPE }}" >> .env.personal |
|
- name: Setup private npm |
|
run: npx private-npm-setup@latest |
|
- name: Install dependencies |
|
run: yarn install |
|
|
|
pod-install: |
|
name: Pod Installation |
|
runs-on: ['self-hosted', '${{ inputs.runner }}'] |
|
steps: |
|
- name: Checkout repository |
|
uses: actions/checkout@v2 |
|
- name: Install Pods |
|
run: npx pod-install |