From 4405613430a36050b4b8f92bc56482ca7ad87417 Mon Sep 17 00:00:00 2001 From: rlespinasse Date: Thu, 9 Dec 2021 22:20:56 +0100 Subject: [PATCH] feat: use composite action instead of node Using composite with two actions: - rlespinasse/slugify-value for the SLUG features - rlespinasse/shortify-git-revision for the SHORT feature Since the SHORT sha is now based on a shorted git revision, and no more on a fix substring. BREAKING CHANGE: use different backend for the action --- action.yml | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index fcd3934..dcb6e92 100644 --- a/action.yml +++ b/action.yml @@ -1,9 +1,62 @@ name: "GitHub Slug Action" description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow" -author: 'rlespinasse' -runs: - using: 'node12' - main: 'dist/index.js' +author: "Romain Lespinasse" branding: icon: "minimize" color: "blue" +runs: + using: "composite" + steps: + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_REPOSITORY + value: ${{ github.repository }} + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_REF + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_HEAD_REF + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_BASE_REF + + # Specific values + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_EVENT_REF + value: ${{ github.event.ref }} + + # Calculated values + - id: get-github-ref-name + run: echo "::set-output name=github-ref-name::$(echo "${{ github.head_ref || github.ref }}" | cut -d/ -f3)" + shell: bash + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_REF_NAME + value: ${{ steps.get-github-ref-name.outputs.github-ref-name }} + - id: get-github-repository-owner-part + run: echo "::set-output name=github-repository-owner-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f1)" + shell: bash + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_REPOSITORY_OWNER_PART + value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }} + - id: get-github-repository-name-part + run: echo "::set-output name=github-repository-name-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f2)" + shell: bash + - uses: rlespinasse/slugify-value@v1.1.0 + with: + key: GITHUB_REPOSITORY_NAME_PART + value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }} + + # Short + - uses: rlespinasse/shortify-git-revision@v1.2.0 + with: + name: GITHUB_SHA + continue-on-error: true + - uses: rlespinasse/shortify-git-revision@v1.2.0 + with: + name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA + revision: ${{ github.event.pull_request.head.sha }} + continue-on-error: true