fixing sign-commits boolean variable conditionals

This commit is contained in:
Eduardo Robles Elvira 2022-07-15 11:54:46 +01:00
parent 96af8bfbfc
commit e23c52bb51
No known key found for this signature in database
GPG Key ID: 491C6606E148460C
1 changed files with 9 additions and 22 deletions

View File

@ -52,7 +52,7 @@ inputs:
sign-commits: sign-commits:
description: 'Set to true if the action should sign the commit with GPG' description: 'Set to true if the action should sign the commit with GPG'
required: false required: false
default: '' default: 'false'
gpg-private-key: gpg-private-key:
description: 'GPG Private Key with which to sign the commits in the PR to be created' description: 'GPG Private Key with which to sign the commits in the PR to be created'
required: false required: false
@ -69,7 +69,7 @@ runs:
using: "composite" using: "composite"
steps: steps:
- name: Import bot's GPG key for signing commits - name: Import bot's GPG key for signing commits
if: ${{ inputs.sign-commits }} if: ${{ inputs.sign-commits == 'true' }}
id: import-gpg id: import-gpg
uses: crazy-max/ghaction-import-gpg@v4 uses: crazy-max/ghaction-import-gpg@v4
with: with:
@ -79,10 +79,9 @@ runs:
git_user_signingkey: true git_user_signingkey: true
git_commit_gpgsign: true git_commit_gpgsign: true
- name: Set environment variables (signed commits) - name: Set environment variables (signed commits)
if: ${{ inputs.sign-commits }} if: ${{ inputs.sign-commits == 'true' }}
shell: bash shell: bash
env: env:
SIGN_COMMITS: ${{ inputs.sign-commits }}
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }} GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }} GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }} GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }}
@ -90,24 +89,12 @@ runs:
TARGETS: ${{ inputs.inputs }} TARGETS: ${{ inputs.inputs }}
run: | run: |
echo "GIT_AUTHOR_NAME=$GIT_AUTHOR_NAME" >> $GITHUB_ENV echo "GIT_AUTHOR_NAME=$GIT_AUTHOR_NAME" >> $GITHUB_ENV
echo "GIT_AUTHOR_EMAIL=$GIT_AUTHOR_EMAIL" >> $GITHUB_ENV echo "GIT_AUTHOR_EMAIL=<$GIT_AUTHOR_EMAIL>" >> $GITHUB_ENV
echo "GIT_COMMITTER_NAME=$GIT_COMMITTER_NAME" >> $GITHUB_ENV echo "GIT_COMMITTER_NAME=$GIT_COMMITTER_NAME" >> $GITHUB_ENV
echo "GIT_COMMITTER_EMAIL=$GIT_COMMITTER_EMAIL" >> $GITHUB_ENV echo "GIT_COMMITTER_EMAIL=<$GIT_COMMITTER_EMAIL>" >> $GITHUB_ENV
echo "TARGETS=$TARGETS" >> $GITHUB_ENV - name: Set environment variables (unsigned commits)
GIT_COMMIT_MESSAGE="$(git log --format=%b -n 1)" if: ${{ inputs.sign-commits != 'true' }}
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//'%'/'%25'}"
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//$'\n'/'%0A'}"
GIT_COMMIT_MESSAGE="${GIT_COMMIT_MESSAGE//$'\r'/'%0D'}"
echo "GIT_COMMIT_MESSAGE=$GIT_COMMIT_MESSAGE" >> $GITHUB_ENV
- name: Set environment variables
if: ${{ !inputs.sign-commits }}
shell: bash shell: bash
env:
SIGN_COMMITS: ${{ inputs.sign-commits }}
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }}
run: | run: |
echo "GIT_AUTHOR_NAME=github-actions[bot]" >> $GITHUB_ENV echo "GIT_AUTHOR_NAME=github-actions[bot]" >> $GITHUB_ENV
echo "GIT_AUTHOR_EMAIL=<github-actions[bot]@users.noreply.github.com>" >> $GITHUB_ENV echo "GIT_AUTHOR_EMAIL=<github-actions[bot]@users.noreply.github.com>" >> $GITHUB_ENV
@ -154,8 +141,8 @@ runs:
with: with:
branch: ${{ inputs.branch }} branch: ${{ inputs.branch }}
delete-branch: true delete-branch: true
committer: ${{ env.GIT_COMMITTER_NAME }} <${{ env.GIT_COMMITTER_EMAIL }}> committer: ${{ env.GIT_COMMITTER_NAME }} ${{ env.GIT_COMMITTER_EMAIL }}
author: ${{ env.GIT_AUTHOR_NAME }} <${{ env.GIT_AUTHOR_EMAIL }}> author: ${{ env.GIT_AUTHOR_NAME }} ${{ env.GIT_AUTHOR_EMAIL }}
title: ${{ inputs.pr-title }} title: ${{ inputs.pr-title }}
token: ${{ inputs.token }} token: ${{ inputs.token }}
labels: ${{ inputs.pr-labels }} labels: ${{ inputs.pr-labels }}