Convert reusable workflows to actions (#9816)

This commit is contained in:
Álvaro Mondéjar 2023-11-05 20:35:53 +01:00 committed by GitHub
parent 361702ae9f
commit 380ecdaba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 53 deletions

20
.github/actions/get-labels/action.yml vendored Normal file
View file

@ -0,0 +1,20 @@
name: Get issue/pull request labels
description: Get the current labels of an issue or pull request through the GitHub API
inputs:
issue_number:
description: Issue or pull request number to get labels from
required: true
outputs:
labels:
description: Labels of the issue or pull request
value: ${{ steps.get-labels.outputs.labels }}
runs:
using: composite
steps:
- id: get-labels
shell: sh
run: |
labels="$(gh api 'repos/simple-icons/simple-icons/issues/${{ inputs.issue_number }}' --jq '.labels.[].name')"
echo "labels=$labels" >> $GITHUB_OUTPUT

16
.github/actions/get-version/action.yml vendored Normal file
View file

@ -0,0 +1,16 @@
name: Get version
description: Get the current version of the project
outputs:
version:
description: The version of the project
value: ${{ steps.get-version.outputs.version }}
runs:
using: composite
steps:
- id: get-version
shell: sh
run: |
version="$(grep version -m 1 -i package.json | sed 's/[ \",:version]//g')"
echo "version=$version" >> $GITHUB_OUTPUT

View file

@ -21,7 +21,7 @@ jobs:
MY_GITHUB_TOKEN: ${{ secrets.AUTO_ASSIGN_WORKFLOW_TOKEN }} MY_GITHUB_TOKEN: ${{ secrets.AUTO_ASSIGN_WORKFLOW_TOKEN }}
steps: steps:
- id: get-labels - id: get-labels
uses: ./.github/workflows/get-labels.yml uses: ./.github/actions/get-labels
with: with:
issue_number: ${{ github.event.pull_request.number }} issue_number: ${{ github.event.pull_request.number }}

View file

@ -19,7 +19,7 @@ jobs:
fi fi
- id: get-labels - id: get-labels
uses: ./.github/workflows/get-labels.yml uses: ./.github/actions/get-labels
with: with:
issue_number: ${{ github.event.issue.number }} issue_number: ${{ github.event.issue.number }}

View file

@ -1,27 +0,0 @@
# Get the current labels of an issue or pull request through the GitHub API
name: Get issue/pull request labels
on:
workflow_call:
inputs:
issue_number:
description: Issue or pull request number to get labels from
required: true
type: number
outputs:
labels:
description: Labels of the issue or pull request
value: ${{ jobs.get-labels.outputs.labels }}
jobs:
get-labels:
name: Get labels
runs-on: ubuntu-latest
outputs:
labels: ${{ steps.get-labels.outputs.labels }}
steps:
- id: get-labels
name: Get labels using GitHub API
run: |
labels="$(gh api 'repos/simple-icons/simple-icons/issues/${{ inputs.issue_number }}' --jq '.labels.[].name')"
echo "labels=$labels" >> $GITHUB_OUTPUT

View file

@ -1,22 +0,0 @@
# Get the current version
name: Get version
on:
workflow_call:
outputs:
version:
description: The version of the project
value: ${{ jobs.get-version.outputs.version }}
jobs:
get-version:
name: Get version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Get version from package.json
id: get-version
run: |
version="$(grep version -m 1 -i package.json | sed 's/[ \",:version]//g')"
echo "version=$version" >> $GITHUB_OUTPUT

View file

@ -49,7 +49,7 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-node- ${{ runner.os }}-node-
- id: get-version - id: get-version
uses: ./.github/workflows/get-version.yml uses: ./.github/actions/get-version
- name: Install dependencies - name: Install dependencies
run: npm i run: npm i
- name: Replace CDN theme image links from README - name: Replace CDN theme image links from README
@ -73,7 +73,7 @@ jobs:
id: commit id: commit
uses: kceb/git-message-action@v2 uses: kceb/git-message-action@v2
- id: get-version - id: get-version
uses: ./.github/workflows/get-version.yml uses: ./.github/actions/get-version
- name: Replace CDN theme image links from README - name: Replace CDN theme image links from README
run: node ./scripts/release/strip-theme-links.js "${{ steps.get-version.outputs.version }}" run: node ./scripts/release/strip-theme-links.js "${{ steps.get-version.outputs.version }}"
- name: Configure GIT credentials - name: Configure GIT credentials