From 21e4332bcb534b579de3f040902eab24455b0ec8 Mon Sep 17 00:00:00 2001 From: Sreekara Gotluru <144159344+sgotluru@users.noreply.github.com> Date: Thu, 9 Jan 2025 23:33:39 -0600 Subject: [PATCH 01/24] Create greetings.yml --- .github/workflows/greetings.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/greetings.yml diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml new file mode 100644 index 000000000..46774343e --- /dev/null +++ b/.github/workflows/greetings.yml @@ -0,0 +1,16 @@ +name: Greetings + +on: [pull_request_target, issues] + +jobs: + greeting: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: "Message that will be displayed on users' first issue" + pr-message: "Message that will be displayed on users' first pull request" From ca1587e4bf52cc8df386bd1b649818664ea116bd Mon Sep 17 00:00:00 2001 From: Sreekara Gotluru <144159344+sgotluru@users.noreply.github.com> Date: Fri, 10 Jan 2025 01:39:36 -0600 Subject: [PATCH 02/24] add new schedule.yml file --- .github/workflows/schedule.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/schedule.yml diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml new file mode 100644 index 000000000..0ca62f606 --- /dev/null +++ b/.github/workflows/schedule.yml @@ -0,0 +1,10 @@ +on: + schedule: + - cron: '*/2 * * * *' + +jobs: + hello_world: + runs-on: ubuntu-latest + steps: + - name: Echo current time + run: echo "The current server time is $(date)" From 91956050264ca91cfeffd975fa0db5cf80600885 Mon Sep 17 00:00:00 2001 From: Sreekara Gotluru <144159344+sgotluru@users.noreply.github.com> Date: Fri, 10 Jan 2025 01:49:09 -0600 Subject: [PATCH 03/24] add multi event trigger yml --- .github/workflows/multi-event.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/multi-event.yml diff --git a/.github/workflows/multi-event.yml b/.github/workflows/multi-event.yml new file mode 100644 index 000000000..a3275be38 --- /dev/null +++ b/.github/workflows/multi-event.yml @@ -0,0 +1,19 @@ +on: + push: + branches: + - main + - dev + pull_request: + branches: + - main + +jobs: + hello_world: + runs-on: ubuntu-latest + steps: + - name: "Echo Basic Information" + run: | + echo "REF: $GITHUB_REF" + echo "Job ID: $GITHUB_JOB" + echo "Action: $GITHUB_ACTION" + echo "Actor: $GITHUB_ACTOR" \ No newline at end of file From 2daf54772ee7a3e7944219314c12e23aaa64548e Mon Sep 17 00:00:00 2001 From: Sreekara Gotluru <144159344+sgotluru@users.noreply.github.com> Date: Fri, 10 Jan 2025 01:58:21 -0600 Subject: [PATCH 04/24] trigger a new change in dev branch --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 43fc9143d..d6c276977 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Github-Examples A repo containing GitHub for programmatic examples + +## This is to check if it can trigger my workflow \ No newline at end of file From b09e6ca6342abb339e857be46976c2b5dae745fe Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Fri, 10 Jan 2025 03:06:04 -0600 Subject: [PATCH 05/24] add .gitignore to exclude Visual Studio Code files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..ffe9c8016 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Ignore Visual Studio Code files +.vscode/ \ No newline at end of file From 41776ad057460a3ef6478b048fb30284f4839a9a Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Fri, 10 Jan 2025 04:34:40 -0600 Subject: [PATCH 06/24] remove .gitignore and add manual trigger workflow with parameters --- .github/workflows/manual.yml | 32 ++++++++++++++++++++++++++++++++ .github/workflows/mydata | 2 ++ .gitignore | 2 -- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/manual.yml create mode 100644 .github/workflows/mydata delete mode 100644 .gitignore diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 000000000..081adf3a6 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,32 @@ +name: Manual Trigger with Params + +on: + workflow_dispatch: + inputs: + name: + description: 'Name of the person to greet' + required: true + type: string + greeting: + description: 'Type of greeting' + required: true + type: string + data: + description: 'Base64 encoded content of a file' + required: false + type: string + +jobs: + greet: + runs-on: ubuntu-latest + steps: + - name: Decode File Content + run: | + echo "${{ inputs.data }}" | base64 --decode > ./decoded_file.txt + - name: Display Greeting + run: | + echo "${{ inputs.greeting }}, ${{ inputs.name }}!" + - name: Display File Content + run: | + echo "Contents of the file:" + cat ./decoded_file.txt \ No newline at end of file diff --git a/.github/workflows/mydata b/.github/workflows/mydata new file mode 100644 index 000000000..71f32fff2 --- /dev/null +++ b/.github/workflows/mydata @@ -0,0 +1,2 @@ +// {"Hello" : "Mars"} +SGVsbG8gTWFycw== \ No newline at end of file diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ffe9c8016..000000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore Visual Studio Code files -.vscode/ \ No newline at end of file From 4d5dba8e014d93136b8b091413ba8a0a05907082 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Fri, 10 Jan 2025 23:52:55 -0600 Subject: [PATCH 07/24] remove obsolete workflow files and add webhook event example --- .github/workflows/custom-action.yml | 15 -------------- .github/workflows/greetings.yml | 16 --------------- .github/workflows/manual.yml | 32 ----------------------------- .github/workflows/multi-event.yml | 19 ----------------- .github/workflows/mydata | 2 -- .github/workflows/schedule.yml | 10 --------- .github/workflows/webhook.yml | 15 ++++++++++++++ 7 files changed, 15 insertions(+), 94 deletions(-) delete mode 100644 .github/workflows/custom-action.yml delete mode 100644 .github/workflows/greetings.yml delete mode 100644 .github/workflows/manual.yml delete mode 100644 .github/workflows/multi-event.yml delete mode 100644 .github/workflows/mydata delete mode 100644 .github/workflows/schedule.yml create mode 100644 .github/workflows/webhook.yml diff --git a/.github/workflows/custom-action.yml b/.github/workflows/custom-action.yml deleted file mode 100644 index 7a87b53f1..000000000 --- a/.github/workflows/custom-action.yml +++ /dev/null @@ -1,15 +0,0 @@ -on: [push] - -jobs: - my-job: - runs-on: ubuntu-latest - name: A job to say hello - steps: - - name: Hello world action step - id: hello - uses: omenking/barsoom@0.0.6 - with: - name: 'Brown' - # Use the output from the `hello` step - - name: Get the Output - run: echo "The time was ${{ steps.hello.outputs.greeting }}" \ No newline at end of file diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml deleted file mode 100644 index 46774343e..000000000 --- a/.github/workflows/greetings.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Greetings - -on: [pull_request_target, issues] - -jobs: - greeting: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: "Message that will be displayed on users' first issue" - pr-message: "Message that will be displayed on users' first pull request" diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml deleted file mode 100644 index 081adf3a6..000000000 --- a/.github/workflows/manual.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Manual Trigger with Params - -on: - workflow_dispatch: - inputs: - name: - description: 'Name of the person to greet' - required: true - type: string - greeting: - description: 'Type of greeting' - required: true - type: string - data: - description: 'Base64 encoded content of a file' - required: false - type: string - -jobs: - greet: - runs-on: ubuntu-latest - steps: - - name: Decode File Content - run: | - echo "${{ inputs.data }}" | base64 --decode > ./decoded_file.txt - - name: Display Greeting - run: | - echo "${{ inputs.greeting }}, ${{ inputs.name }}!" - - name: Display File Content - run: | - echo "Contents of the file:" - cat ./decoded_file.txt \ No newline at end of file diff --git a/.github/workflows/multi-event.yml b/.github/workflows/multi-event.yml deleted file mode 100644 index a3275be38..000000000 --- a/.github/workflows/multi-event.yml +++ /dev/null @@ -1,19 +0,0 @@ -on: - push: - branches: - - main - - dev - pull_request: - branches: - - main - -jobs: - hello_world: - runs-on: ubuntu-latest - steps: - - name: "Echo Basic Information" - run: | - echo "REF: $GITHUB_REF" - echo "Job ID: $GITHUB_JOB" - echo "Action: $GITHUB_ACTION" - echo "Actor: $GITHUB_ACTOR" \ No newline at end of file diff --git a/.github/workflows/mydata b/.github/workflows/mydata deleted file mode 100644 index 71f32fff2..000000000 --- a/.github/workflows/mydata +++ /dev/null @@ -1,2 +0,0 @@ -// {"Hello" : "Mars"} -SGVsbG8gTWFycw== \ No newline at end of file diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml deleted file mode 100644 index 0ca62f606..000000000 --- a/.github/workflows/schedule.yml +++ /dev/null @@ -1,10 +0,0 @@ -on: - schedule: - - cron: '*/2 * * * *' - -jobs: - hello_world: - runs-on: ubuntu-latest - steps: - - name: Echo current time - run: echo "The current server time is $(date)" diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml new file mode 100644 index 000000000..b2b361c2c --- /dev/null +++ b/.github/workflows/webhook.yml @@ -0,0 +1,15 @@ +name: "Webhook Event example" + +on: + repository_dispatch: + types: + - custom_webhook + +jobs: + respond-to-dispatch: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Run a script + run : echo "Event of type: $GITHUB_EVENT_NAME" From fdba2d783e5a1c8fcc311cf82632a349be7ab561 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Fri, 10 Jan 2025 23:56:32 -0600 Subject: [PATCH 08/24] update webhook event type from 'custom_webhook' to 'webhook' --- .github/workflows/webhook.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index b2b361c2c..a55586435 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -3,7 +3,7 @@ name: "Webhook Event example" on: repository_dispatch: types: - - custom_webhook + - webhook jobs: respond-to-dispatch: From 0d097ed4cf109c863132facf064e48eab61ec4a8 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Fri, 10 Jan 2025 23:59:42 -0600 Subject: [PATCH 09/24] fix formatting in webhook script execution --- .github/workflows/webhook.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index a55586435..29b950b6f 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -12,4 +12,4 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: Run a script - run : echo "Event of type: $GITHUB_EVENT_NAME" + run: echo "Event of type: $GITHUB_EVENT_NAME" \ No newline at end of file From 5557635c9df39f83b7bfde922efda4ba0177b223 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 00:01:20 -0600 Subject: [PATCH 10/24] fix: update echo command syntax in webhook workflow --- .github/workflows/webhook.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index 29b950b6f..e3a34fa5f 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -12,4 +12,4 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: Run a script - run: echo "Event of type: $GITHUB_EVENT_NAME" \ No newline at end of file + run: "echo 'Event of type: $GITHUB_EVENT_NAME'" \ No newline at end of file From da48f48d8d603977864ea5b424a1e38636c4dd1f Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 00:27:14 -0600 Subject: [PATCH 11/24] fix: comment out checkout step in webhook workflow --- .github/workflows/webhook.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index e3a34fa5f..f1f5223a5 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -9,7 +9,7 @@ jobs: respond-to-dispatch: runs-on: ubuntu-latest steps: - - name: Checkout repo - uses: actions/checkout@v2 + # - name: Checkout repo + # uses: actions/checkout@v2 - name: Run a script run: "echo 'Event of type: $GITHUB_EVENT_NAME'" \ No newline at end of file From ac4963b19aa63883aa84d29a5343acafad2abb5e Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 03:35:36 -0600 Subject: [PATCH 12/24] feat: add example workflow with hello world and goodbye moon jobs --- .github/workflows/conditional.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/conditional.yml diff --git a/.github/workflows/conditional.yml b/.github/workflows/conditional.yml new file mode 100644 index 000000000..87b48c2f9 --- /dev/null +++ b/.github/workflows/conditional.yml @@ -0,0 +1,14 @@ +name: example-workflow +on: [push] +jobs: + hello-world: + if: github.repository == 'octo-org/octo-repo-prod' + runs-on: ubuntu-latest + steps: + - name: "Hello World" + run: echo "Hello World!" + goodbye-moon: + runs-on: ubuntu-latest + steps: + - name: "Goodbye Moon" + run: echo "Goodbye Moon!" \ No newline at end of file From 7a94910b10ccc480da3702dceff0a39748ca6668 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 03:38:45 -0600 Subject: [PATCH 13/24] fix: update repository condition in example workflow --- .github/workflows/conditional.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conditional.yml b/.github/workflows/conditional.yml index 87b48c2f9..e577603d0 100644 --- a/.github/workflows/conditional.yml +++ b/.github/workflows/conditional.yml @@ -2,7 +2,7 @@ name: example-workflow on: [push] jobs: hello-world: - if: github.repository == 'octo-org/octo-repo-prod' + if: github.repository == 'sgotluru/Github-Examples' runs-on: ubuntu-latest steps: - name: "Hello World" From 258d1dcff22249fefd7ffebaafe7602ece388fca Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 03:52:27 -0600 Subject: [PATCH 14/24] feat: add expression functions demo workflow with various string checks and JSON parsing --- .github/workflows/expression-functions.yml | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/expression-functions.yml diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml new file mode 100644 index 000000000..7e46d636a --- /dev/null +++ b/.github/workflows/expression-functions.yml @@ -0,0 +1,48 @@ +name: Expression Functions Demo + +on: + push: + branches: + - main + issues: + types: [opened, labeled] + +jobs: + expression-functions: + runs-on: ubuntu-latest + steps: + - name: Check if string contains substring + if: contains('Hello world', 'llo') + run: echo "The string contains the substring." + + - name: Check if string starts with + if: startsWith('Hello world', 'He') + run: echo "The string starts with 'He'." + + - name: Check if string ends with + if: endsWith('Hello world', 'ld') + run: echo "The string ends with 'ld'." + + - name: Format and echo string + run: echo ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }} + + - name: Join issue labels + if: github.event_name == 'issues' + run: "echo 'Issue labels: ${{ join(github.event.issue.labels.*.name, ", ") }}'" + + - name: Convert job context to JSON + run: "echo 'Job context in JSON: ${{ toJSON(github.job) }}'" + + - name: Parse JSON string + run: echo 'Parsed JSON: ${{ fromJSON("{\"hello\":\"world\"}").hello }}' + + - name: Hash files + run: echo 'Hash of files: ${{ hashFiles("**/package-lock.json", "**/Gemfile.lock") }}' + + - name: The job has succeeded + if: success() + run: echo "The job succeeded." + + - name: The job has failed + if: failure() + run: echo "The job failed." From ed3c9152ea5030bef963b8d10e0ca61ab573f400 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 03:53:46 -0600 Subject: [PATCH 15/24] fix: comment out issues trigger in expression functions workflow --- .github/workflows/expression-functions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index 7e46d636a..68e212462 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -4,8 +4,8 @@ on: push: branches: - main - issues: - types: [opened, labeled] + # issues: + # types: [opened, labeled] jobs: expression-functions: From 3fa1eec99a69ac4517b15cd8b0c45b6c4f281a3f Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 03:59:16 -0600 Subject: [PATCH 16/24] fix: uncomment issues trigger and comment out unused steps in expression functions workflow --- .github/workflows/expression-functions.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index 68e212462..e550791b8 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -4,8 +4,8 @@ on: push: branches: - main - # issues: - # types: [opened, labeled] + issues: + types: [opened, labeled] jobs: expression-functions: @@ -26,18 +26,18 @@ jobs: - name: Format and echo string run: echo ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }} - - name: Join issue labels - if: github.event_name == 'issues' - run: "echo 'Issue labels: ${{ join(github.event.issue.labels.*.name, ", ") }}'" + # - name: Join issue labels + # if: github.event_name == 'issues' + # run: echo 'Issue labels: ${{ join(github.event.issue.labels.*.name, ", ") }}' - - name: Convert job context to JSON - run: "echo 'Job context in JSON: ${{ toJSON(github.job) }}'" + # - name: Convert job context to JSON + # run: echo 'Job context in JSON: ${{ toJSON(github.job) }}' - - name: Parse JSON string - run: echo 'Parsed JSON: ${{ fromJSON("{\"hello\":\"world\"}").hello }}' + # - name: Parse JSON string + # run: echo 'Parsed JSON: ${{ fromJSON("{\"hello\":\"world\"}").hello }}' - - name: Hash files - run: echo 'Hash of files: ${{ hashFiles("**/package-lock.json", "**/Gemfile.lock") }}' + # - name: Hash files + # run: echo 'Hash of files: ${{ hashFiles("**/package-lock.json", "**/Gemfile.lock") }}' - name: The job has succeeded if: success() From b387365f0c68fa3d4380212c215c3f81746409e3 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 04:26:41 -0600 Subject: [PATCH 17/24] fix: uncomment and correct handling of expressions in expression functions workflow --- .github/workflows/expression-functions.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index e550791b8..a7ad42416 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -26,18 +26,19 @@ jobs: - name: Format and echo string run: echo ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }} - # - name: Join issue labels - # if: github.event_name == 'issues' - # run: echo 'Issue labels: ${{ join(github.event.issue.labels.*.name, ", ") }}' + - name: Join issue labels + if: github.event_name == 'issues' + run: "echo \"Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}\"" - # - name: Convert job context to JSON - # run: echo 'Job context in JSON: ${{ toJSON(github.job) }}' + - name: Convert job context to JSON + run: "echo \"Job context in JSON: ${{ toJSON(github.job) }}\"" - # - name: Parse JSON string - # run: echo 'Parsed JSON: ${{ fromJSON("{\"hello\":\"world\"}").hello }}' + - name: Parse JSON string + # Correct handling of JSON within an expression + run: "echo \"Parsed JSON: ${{ fromJSON('{\"hello\":\"world\"}').hello }}\"" - # - name: Hash files - # run: echo 'Hash of files: ${{ hashFiles("**/package-lock.json", "**/Gemfile.lock") }}' + - name: Hash files + run: "echo \"Hash of files: ${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }}\"" - name: The job has succeeded if: success() From 08449a415a50a2cf44449e48d4ae24fdf6fdddda Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 04:38:48 -0600 Subject: [PATCH 18/24] chore: remove deprecated workflow files for expression functions and webhooks --- .github/workflows/conditional.yml | 14 ------- .github/workflows/expression-functions.yml | 49 ---------------------- .github/workflows/runner-macos.yml | 30 +++++++++++++ .github/workflows/runner-self-hosted.yml | 17 ++++++++ .github/workflows/runner-windows.yml | 38 +++++++++++++++++ .github/workflows/webhook.yml | 15 ------- 6 files changed, 85 insertions(+), 78 deletions(-) delete mode 100644 .github/workflows/conditional.yml delete mode 100644 .github/workflows/expression-functions.yml create mode 100644 .github/workflows/runner-macos.yml create mode 100644 .github/workflows/runner-self-hosted.yml create mode 100644 .github/workflows/runner-windows.yml delete mode 100644 .github/workflows/webhook.yml diff --git a/.github/workflows/conditional.yml b/.github/workflows/conditional.yml deleted file mode 100644 index e577603d0..000000000 --- a/.github/workflows/conditional.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: example-workflow -on: [push] -jobs: - hello-world: - if: github.repository == 'sgotluru/Github-Examples' - runs-on: ubuntu-latest - steps: - - name: "Hello World" - run: echo "Hello World!" - goodbye-moon: - runs-on: ubuntu-latest - steps: - - name: "Goodbye Moon" - run: echo "Goodbye Moon!" \ No newline at end of file diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml deleted file mode 100644 index a7ad42416..000000000 --- a/.github/workflows/expression-functions.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Expression Functions Demo - -on: - push: - branches: - - main - issues: - types: [opened, labeled] - -jobs: - expression-functions: - runs-on: ubuntu-latest - steps: - - name: Check if string contains substring - if: contains('Hello world', 'llo') - run: echo "The string contains the substring." - - - name: Check if string starts with - if: startsWith('Hello world', 'He') - run: echo "The string starts with 'He'." - - - name: Check if string ends with - if: endsWith('Hello world', 'ld') - run: echo "The string ends with 'ld'." - - - name: Format and echo string - run: echo ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }} - - - name: Join issue labels - if: github.event_name == 'issues' - run: "echo \"Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}\"" - - - name: Convert job context to JSON - run: "echo \"Job context in JSON: ${{ toJSON(github.job) }}\"" - - - name: Parse JSON string - # Correct handling of JSON within an expression - run: "echo \"Parsed JSON: ${{ fromJSON('{\"hello\":\"world\"}').hello }}\"" - - - name: Hash files - run: "echo \"Hash of files: ${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }}\"" - - - name: The job has succeeded - if: success() - run: echo "The job succeeded." - - - name: The job has failed - if: failure() - run: echo "The job failed." diff --git a/.github/workflows/runner-macos.yml b/.github/workflows/runner-macos.yml new file mode 100644 index 000000000..6baa5adf6 --- /dev/null +++ b/.github/workflows/runner-macos.yml @@ -0,0 +1,30 @@ +name: macOS Workflow Example + +on: + push: + branches: + - main + +jobs: + build-and-test: + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Create Swift File + run: | + echo 'print("Hello from Swift on macOS")' > hello.swift + + - name: Install dependencies + run: | + brew install swiftlint + + - name: Run SwiftLint + run: swiftlint + + - name: Compile and run Swift program + run: | + swiftc hello.swift + ./hello \ No newline at end of file diff --git a/.github/workflows/runner-self-hosted.yml b/.github/workflows/runner-self-hosted.yml new file mode 100644 index 000000000..23bb12e71 --- /dev/null +++ b/.github/workflows/runner-self-hosted.yml @@ -0,0 +1,17 @@ +# If you don't create a self-hosted runner you will see: +# Waiting for a runner to pick up this job... +name: Self-hosted Runner Workflow + +on: + push: + branches: + - main + +jobs: + example-job: + runs-on: self-hosted + steps: + - name: Check out repository + uses: actions/checkout@v3 + - name: Run a one-line script + run: echo "Hello from a self-hosted runner!" \ No newline at end of file diff --git a/.github/workflows/runner-windows.yml b/.github/workflows/runner-windows.yml new file mode 100644 index 000000000..3b73f2b2e --- /dev/null +++ b/.github/workflows/runner-windows.yml @@ -0,0 +1,38 @@ +name: Windows Workflow Example + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install dependencies + run: choco install dotnetcore-sdk + shell: powershell + + - name: Compile and run C# program + run: | + Add-Content -Path "Hello.cs" -Value @" + using System; + public class Hello + { + public static void Main() + { + Console.WriteLine("Hello, Windows from C#"); + } + } + "@ + dotnet new console --force --no-restore + Move-Item -Path "Hello.cs" -Destination "Program.cs" -Force + dotnet run + shell: powershell \ No newline at end of file diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml deleted file mode 100644 index f1f5223a5..000000000 --- a/.github/workflows/webhook.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: "Webhook Event example" - -on: - repository_dispatch: - types: - - webhook - -jobs: - respond-to-dispatch: - runs-on: ubuntu-latest - steps: - # - name: Checkout repo - # uses: actions/checkout@v2 - - name: Run a script - run: "echo 'Event of type: $GITHUB_EVENT_NAME'" \ No newline at end of file From c10d1e9aa7def7d02363d3ea0e2bacc784cf6660 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 04:43:42 -0600 Subject: [PATCH 19/24] chore: remove macOS and Windows workflow examples --- .github/workflows/runner-macos.yml | 30 ---------------------- .github/workflows/runner-windows.yml | 38 ---------------------------- 2 files changed, 68 deletions(-) delete mode 100644 .github/workflows/runner-macos.yml delete mode 100644 .github/workflows/runner-windows.yml diff --git a/.github/workflows/runner-macos.yml b/.github/workflows/runner-macos.yml deleted file mode 100644 index 6baa5adf6..000000000 --- a/.github/workflows/runner-macos.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: macOS Workflow Example - -on: - push: - branches: - - main - -jobs: - build-and-test: - runs-on: macos-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Create Swift File - run: | - echo 'print("Hello from Swift on macOS")' > hello.swift - - - name: Install dependencies - run: | - brew install swiftlint - - - name: Run SwiftLint - run: swiftlint - - - name: Compile and run Swift program - run: | - swiftc hello.swift - ./hello \ No newline at end of file diff --git a/.github/workflows/runner-windows.yml b/.github/workflows/runner-windows.yml deleted file mode 100644 index 3b73f2b2e..000000000 --- a/.github/workflows/runner-windows.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Windows Workflow Example - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - build-and-test: - runs-on: windows-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Install dependencies - run: choco install dotnetcore-sdk - shell: powershell - - - name: Compile and run C# program - run: | - Add-Content -Path "Hello.cs" -Value @" - using System; - public class Hello - { - public static void Main() - { - Console.WriteLine("Hello, Windows from C#"); - } - } - "@ - dotnet new console --force --no-restore - Move-Item -Path "Hello.cs" -Destination "Program.cs" -Force - dotnet run - shell: powershell \ No newline at end of file From f9cb0a7c966a4cb46f3c6804e156078000c9a3bd Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 05:36:56 -0600 Subject: [PATCH 20/24] feat: add workflow commands for logging group messages --- .github/workflows/workflow_commands.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/workflow_commands.yml diff --git a/.github/workflows/workflow_commands.yml b/.github/workflows/workflow_commands.yml new file mode 100644 index 000000000..5ba19ef42 --- /dev/null +++ b/.github/workflows/workflow_commands.yml @@ -0,0 +1,13 @@ +name: "Workflow Commands" + +on : ['push'] +jobs: + my_job: + runs-on: ubuntu-latest + steps: + - name: "group logging commands" + run: | + echo "::group::This is a group" + echo "Hello" + echo "World" + echo "::endgroup::" \ No newline at end of file From f7397fb2c7a6aa37eba457eab247d4f6da9c5c23 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 05:41:01 -0600 Subject: [PATCH 21/24] feat: add additional steps to workflow_commands.yml for enhanced functionality --- .github/workflows/workflow_commands.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow_commands.yml b/.github/workflows/workflow_commands.yml index 5ba19ef42..875f712b6 100644 --- a/.github/workflows/workflow_commands.yml +++ b/.github/workflows/workflow_commands.yml @@ -10,4 +10,14 @@ jobs: echo "::group::This is a group" echo "Hello" echo "World" - echo "::endgroup::" \ No newline at end of file + echo "::endgroup::" + - name: "step one" + run: | + echo "This is step one" + echo "x=10" >> $GITHUB_ENV + - name: "step two" + run: echo "This is step two" + - name: "step three" + run: | + echo "This is step three" + echo "x=$x" \ No newline at end of file From 207eaa1e122e231f66271ce4a00d7e2d35603090 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 05:42:12 -0600 Subject: [PATCH 22/24] fix: adjust indentation for consistency in workflow_commands.yml --- .github/workflows/workflow_commands.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow_commands.yml b/.github/workflows/workflow_commands.yml index 875f712b6..56c07007e 100644 --- a/.github/workflows/workflow_commands.yml +++ b/.github/workflows/workflow_commands.yml @@ -12,12 +12,12 @@ jobs: echo "World" echo "::endgroup::" - name: "step one" - run: | - echo "This is step one" - echo "x=10" >> $GITHUB_ENV + run: | + echo "This is step one" + echo "x=10" >> $GITHUB_ENV - name: "step two" - run: echo "This is step two" + run: echo "This is step two" - name: "step three" - run: | - echo "This is step three" - echo "x=$x" \ No newline at end of file + run: | + echo "This is step three" + echo "x=$x" \ No newline at end of file From 1f9b6f8966f73b3a58f25efd9f0972ee53d58c70 Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 05:48:30 -0600 Subject: [PATCH 23/24] chore: remove obsolete self-hosted runner and workflow commands files --- .github/workflows/context.yml | 23 +++++++++++++++++++++++ .github/workflows/runner-self-hosted.yml | 17 ----------------- .github/workflows/workflow_commands.yml | 23 ----------------------- 3 files changed, 23 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/context.yml delete mode 100644 .github/workflows/runner-self-hosted.yml delete mode 100644 .github/workflows/workflow_commands.yml diff --git a/.github/workflows/context.yml b/.github/workflows/context.yml new file mode 100644 index 000000000..ee1eca5df --- /dev/null +++ b/.github/workflows/context.yml @@ -0,0 +1,23 @@ +name: Context Example Workflow + +on: [push] + +jobs: + example-job: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Print GitHub context + run: "echo \"Repository: ${{ github.repository }}\"" + + - name: Print Job context + run: "echo \"Job ID: ${{ job.id }}\"" + + - name: Print Runner context + run: "echo \"Runner OS: ${{ runner.os }}\"" + + - name: Print Secrets context + run: "echo \"Secret Token: ${{ secrets.GITHUB_TOKEN }}\"" \ No newline at end of file diff --git a/.github/workflows/runner-self-hosted.yml b/.github/workflows/runner-self-hosted.yml deleted file mode 100644 index 23bb12e71..000000000 --- a/.github/workflows/runner-self-hosted.yml +++ /dev/null @@ -1,17 +0,0 @@ -# If you don't create a self-hosted runner you will see: -# Waiting for a runner to pick up this job... -name: Self-hosted Runner Workflow - -on: - push: - branches: - - main - -jobs: - example-job: - runs-on: self-hosted - steps: - - name: Check out repository - uses: actions/checkout@v3 - - name: Run a one-line script - run: echo "Hello from a self-hosted runner!" \ No newline at end of file diff --git a/.github/workflows/workflow_commands.yml b/.github/workflows/workflow_commands.yml deleted file mode 100644 index 56c07007e..000000000 --- a/.github/workflows/workflow_commands.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: "Workflow Commands" - -on : ['push'] -jobs: - my_job: - runs-on: ubuntu-latest - steps: - - name: "group logging commands" - run: | - echo "::group::This is a group" - echo "Hello" - echo "World" - echo "::endgroup::" - - name: "step one" - run: | - echo "This is step one" - echo "x=10" >> $GITHUB_ENV - - name: "step two" - run: echo "This is step two" - - name: "step three" - run: | - echo "This is step three" - echo "x=$x" \ No newline at end of file From 41f924fe631ebbcbbe89f8daa6d474d07b1aa49c Mon Sep 17 00:00:00 2001 From: sreekara_gotluru Date: Sat, 11 Jan 2025 05:49:47 -0600 Subject: [PATCH 24/24] fix: update job context output to use correct GitHub run ID --- .github/workflows/context.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/context.yml b/.github/workflows/context.yml index ee1eca5df..6a6348ced 100644 --- a/.github/workflows/context.yml +++ b/.github/workflows/context.yml @@ -14,7 +14,7 @@ jobs: run: "echo \"Repository: ${{ github.repository }}\"" - name: Print Job context - run: "echo \"Job ID: ${{ job.id }}\"" + run: "echo \"Job ID: ${{ github.run_id }}\"" - name: Print Runner context run: "echo \"Runner OS: ${{ runner.os }}\""