Update 01-run-trofflehog.yaml #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 00-first workflow | |
on: | |
push: | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch to test' | |
type: string | |
default: 'dev' | |
input1: | |
description: 'Input 1' | |
type: string | |
default: 'efg' | |
input2: | |
description: 'Input 2' | |
type: number | |
default: 123 | |
jobs: | |
job1: | |
runs-on: ubuntu-latest | |
env: | |
ENV_VAR1: 1234 | |
ENV_VAR2: "abcd" | |
ENV_VAR3: ${{ github.event.inputs.input1 }} | |
ENV_VAR4: ${{ github.event.inputs.input2 }} | |
steps: | |
- name: Trigger | |
run: echo "Triggered by ${{ github.event_name }} event" | |
- name: Check Branch Input | |
run: | | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
if [ -z "${{ github.event.inputs.branch }}" ]; then | |
echo "Branch input is required for manual trigger." | |
exit 1 | |
else | |
BRANCH_NAME="${{ github.event.inputs.branch }}" | |
fi | |
else | |
# Extract branch name from github.ref | |
BRANCH_NAME="${{ github.ref }}" | |
BRANCH_NAME="${BRANCH_NAME##*/}" # This removes everything before the last '/' | |
fi | |
echo "Checkout branch $BRANCH_NAME" | |
- name: Verify directory1 | |
run: | | |
echo "Repo root directory: $GITHUB_WORKSPACE" | |
echo "Current directory: $PWD" | |
echo "Cloned to: $(pwd)" | |
ls -la /home/runner/work/${{ github.event.repository.name }} | |
ls -la $GITHUB_WORKSPACE | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }} | |
- name: Verify directory2 | |
run: | | |
echo "Repo root directory: $GITHUB_WORKSPACE" | |
echo "Current directory: $PWD" | |
echo "Cloned to: $(pwd)" | |
echo "ls -la /home/runner/work/${{ github.event.repository.name }}:" | |
ls -la /home/runner/work/${{ github.event.repository.name }} | |
echo "ls -la $GITHUB_WORKSPACE" | |
ls -la $GITHUB_WORKSPACE | |
- name: Move to custom workspace | |
run: | | |
mv "$GITHUB_WORKSPACE"/* "$(dirname "$GITHUB_WORKSPACE")" | |
#rm -rf "$GITHUB_WORKSPACE" # Delete the empty folder | |
echo "Current directory: $PWD" | |
cd .. | |
tree "$(pwd)" | |
echo "Current directory: $PWD" | |
- name: Verify directory3 | |
run: | | |
echo "Current directory: $PWD" | |
echo "Cloned to: $(pwd)" | |
echo "ls -la /home/runner/work/${{ github.event.repository.name }}:" | |
ls -la /home/runner/work/${{ github.event.repository.name }} | |
- name: Log Current Branch and Commit | |
run: | | |
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" | |
echo "Current commit: $(git rev-parse HEAD)" | |
- name: Create output | |
run: | | |
echo "This job is running on Ubuntu!" | |
mkdir -p ${{ github.workspace }}/output/child_folder1/test2 | |
echo "Hello from Job 1" > output/child_folder1/test2/message.txt | |
ls -R | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: job1-output | |
path: ./output | |
job2: | |
runs-on: windows-latest | |
needs: job1 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Log Current Branch and Commit | |
run: | | |
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" | |
echo "Current commit: $(git rev-parse HEAD)" | |
dir | |
cd test_folder | |
- name: Download output from Job 1 | |
uses: actions/download-artifact@v3 | |
with: | |
name: job1-output | |
- name: Run on Windows | |
run: | | |
echo "This job is running on Windows!" | |
dir | |
type job1-output\message.txt | |
echo "Output folder" | |
dir child_folder1 | |
move child_folder1\* .. | |
echo "List folder" | |
dir | |