Skip to content

Commit

Permalink
feat: add working directory input to workflow
Browse files Browse the repository at this point in the history
Added a new 'workingdir' input to the GitHub Actions workflow. This allows for specifying the working directory when running commands. The changes include:
- Added 'workingdir' as an optional input in the workflow_call section.
- Updated testifysec/witness-run-action usage to include 'workingdir'.
- Set 'working-directory' for run commands when pull_request is true.
This enhancement provides more flexibility in configuring workflows, especially when dealing with projects that have complex structures or require specific execution contexts.
  • Loading branch information
kriscoleman committed Jan 15, 2025
1 parent 88f2233 commit 32a0141
Show file tree
Hide file tree
Showing 3 changed files with 1,162 additions and 976 deletions.
151 changes: 79 additions & 72 deletions .github/workflows/witness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,87 @@
# limitations under the License.

on:
workflow_call:
inputs:
pull_request:
required: true
type: boolean
artifact-download:
required: false
type: string
artifact-upload-name:
required: false
type: string
artifact-upload-path:
required: false
type: string
pre-command:
required: false
type: string
pre-command-attestations:
default: "environment git github"
required: false
type: string
command:
required: true
type: string
step:
required: true
type: string
attestations:
required: true
type: string
archivista-server:
default: "https://archivista.testifysec.io"
required: false
type: string

workflow_call:
inputs:
pull_request:
required: true
type: boolean
artifact-download:
required: false
type: string
artifact-upload-name:
required: false
type: string
artifact-upload-path:
required: false
type: string
pre-command:
required: false
type: string
pre-command-attestations:
default: 'environment git github'
required: false
type: string
command:
required: true
type: string
step:
required: true
type: string
attestations:
required: true
type: string
archivista-server:
default: 'https://archivista.testifysec.io'
required: false
type: string
workingdir:
required: false
type: string

jobs:
witness:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.21.x
witness:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.21.x

- if: ${{ inputs.artifact-download != '' }}
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: ${{ inputs.artifact-download }}
path: /tmp
- if: ${{ inputs.artifact-download != '' }}
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: ${{ inputs.artifact-download }}
path: /tmp

- if: ${{ inputs.pre-command != '' && inputs.pull_request == false }}
uses: testifysec/witness-run-action@79320a907f611f2fb40ced8e13c66af988b2d9db # v0.2.2
with:
version: 0.6.0
archivista-server: ${{ inputs.archivista-server }}
step: pre-${{ inputs.step }}
attestations: ${{ inputs.pre-command-attestations }}
command: /bin/sh -c "${{ inputs.pre-command }}"
- if: ${{ inputs.pre-command != '' && inputs.pull_request == true }}
run: ${{ inputs.pre-command }}
- if: ${{ inputs.pre-command != '' && inputs.pull_request == false }}
uses: testifysec/witness-run-action@workingdir-input
with:
version: 0.6.0
archivista-server: ${{ inputs.archivista-server }}
step: pre-${{ inputs.step }}
attestations: ${{ inputs.pre-command-attestations }}
workingdir: ${{ inputs.workingdir }}
command: /bin/sh -c "${{ inputs.pre-command }}"
- if: ${{ inputs.pre-command != '' && inputs.pull_request == true }}
run: ${{ inputs.pre-command }}
working-directory: ${{ inputs.workingdir }}

- if: ${{ inputs.pull_request == false }}
uses: testifysec/witness-run-action@79320a907f611f2fb40ced8e13c66af988b2d9db # v0.2.2
with:
version: 0.6.0
archivista-server: ${{ inputs.archivista-server }}
step: ${{ inputs.step }}
attestations: ${{ inputs.attestations }}
command: /bin/sh -c "${{ inputs.command }}"
- if: ${{ inputs.pull_request == true }}
run: ${{ inputs.command }}
- if: ${{ inputs.pull_request == false }}
uses: testifysec/witness-run-action@workingdir-input
with:
version: 0.6.0
archivista-server: ${{ inputs.archivista-server }}
step: ${{ inputs.step }}
attestations: ${{ inputs.attestations }}
workingdir: ${{ inputs.workingdir }}
command: /bin/sh -c "${{ inputs.command }}"
- if: ${{ inputs.pull_request == true }}
run: ${{ inputs.command }}
working-directory: ${{ inputs.workingdir }}

- if: ${{ inputs.artifact-upload-path != '' && inputs.artifact-upload-name != ''}}
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: ${{ inputs.artifact-upload-name }}
path: ${{ inputs.artifact-upload-path }}
- if: ${{ inputs.artifact-upload-path != '' && inputs.artifact-upload-name != ''}}
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: ${{ inputs.artifact-upload-name }}
path: ${{ inputs.artifact-upload-path }}
Loading

0 comments on commit 32a0141

Please sign in to comment.