diff --git a/.github/actions/get-labels/action.yml b/.github/actions/get-labels/action.yml new file mode 100644 index 000000000..8c242ab71 --- /dev/null +++ b/.github/actions/get-labels/action.yml @@ -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 diff --git a/.github/actions/get-version/action.yml b/.github/actions/get-version/action.yml new file mode 100644 index 000000000..ada9e8902 --- /dev/null +++ b/.github/actions/get-version/action.yml @@ -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 diff --git a/.github/workflows/add-labels-priority.yml b/.github/workflows/add-labels-priority.yml index 0d5bee5a4..ed4304d77 100644 --- a/.github/workflows/add-labels-priority.yml +++ b/.github/workflows/add-labels-priority.yml @@ -21,7 +21,7 @@ jobs: MY_GITHUB_TOKEN: ${{ secrets.AUTO_ASSIGN_WORKFLOW_TOKEN }} steps: - id: get-labels - uses: ./.github/workflows/get-labels.yml + uses: ./.github/actions/get-labels with: issue_number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/autoclose-issues.yml b/.github/workflows/autoclose-issues.yml index 33b9b3348..2cbf35d99 100644 --- a/.github/workflows/autoclose-issues.yml +++ b/.github/workflows/autoclose-issues.yml @@ -19,7 +19,7 @@ jobs: fi - id: get-labels - uses: ./.github/workflows/get-labels.yml + uses: ./.github/actions/get-labels with: issue_number: ${{ github.event.issue.number }} diff --git a/.github/workflows/get-labels.yml b/.github/workflows/get-labels.yml deleted file mode 100644 index 7052877f6..000000000 --- a/.github/workflows/get-labels.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/get-version.yml b/.github/workflows/get-version.yml deleted file mode 100644 index 948d4b86c..000000000 --- a/.github/workflows/get-version.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3b6a22bec..51e5af4e7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -49,7 +49,7 @@ jobs: restore-keys: | ${{ runner.os }}-node- - id: get-version - uses: ./.github/workflows/get-version.yml + uses: ./.github/actions/get-version - name: Install dependencies run: npm i - name: Replace CDN theme image links from README @@ -73,7 +73,7 @@ jobs: id: commit uses: kceb/git-message-action@v2 - id: get-version - uses: ./.github/workflows/get-version.yml + uses: ./.github/actions/get-version - name: Replace CDN theme image links from README run: node ./scripts/release/strip-theme-links.js "${{ steps.get-version.outputs.version }}" - name: Configure GIT credentials