From 734b5bcbd00c1a0d32853fbf2f3e2b48419085a9 Mon Sep 17 00:00:00 2001 From: Chandrashekhar <67406458+mehtachandrashekhar@users.noreply.github.com> Date: Sat, 8 Jun 2024 22:10:23 +0530 Subject: [PATCH 01/29] 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 00000000..46774343 --- /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 5c9a3d82013bc4979d7eaba26572a7e82fcde71e Mon Sep 17 00:00:00 2001 From: Chandrashekhar <67406458+mehtachandrashekhar@users.noreply.github.com> Date: Sun, 9 Jun 2024 09:32:01 +0530 Subject: [PATCH 02/29] cron workflow -/5min --- .github/workflows/schedule.yml | 10 ++++++++++ github-actions/templates/schedule copy.yml | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .github/workflows/schedule.yml create mode 100644 github-actions/templates/schedule copy.yml diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml new file mode 100644 index 00000000..a88231de --- /dev/null +++ b/.github/workflows/schedule.yml @@ -0,0 +1,10 @@ +on: + schedule: + - cron: '*/5 * * * *' + +jobs: + hello_world: + runs-on: ubuntu-latest + steps: + - name: Echo current time + run: echo "The current server time is $(date)" diff --git a/github-actions/templates/schedule copy.yml b/github-actions/templates/schedule copy.yml new file mode 100644 index 00000000..a88231de --- /dev/null +++ b/github-actions/templates/schedule copy.yml @@ -0,0 +1,10 @@ +on: + schedule: + - cron: '*/5 * * * *' + +jobs: + hello_world: + runs-on: ubuntu-latest + steps: + - name: Echo current time + run: echo "The current server time is $(date)" From 499c41a9095009bd54ebc8c36ab7f4e6f11a2a77 Mon Sep 17 00:00:00 2001 From: Chandrashekhar <67406458+mehtachandrashekhar@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:01:35 +0530 Subject: [PATCH 03/29] multi event trigger --- .github/workflows/greetings.yml | 16 ---------------- .github/workflows/multi-event.yml | 19 +++++++++++++++++++ github-actions/templates/greetings.yml | 1 - 3 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 .github/workflows/greetings.yml create mode 100644 .github/workflows/multi-event.yml diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml deleted file mode 100644 index 46774343..00000000 --- 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/multi-event.yml b/.github/workflows/multi-event.yml new file mode 100644 index 00000000..a3275be3 --- /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 diff --git a/github-actions/templates/greetings.yml b/github-actions/templates/greetings.yml index 996da6bb..46774343 100644 --- a/github-actions/templates/greetings.yml +++ b/github-actions/templates/greetings.yml @@ -9,7 +9,6 @@ jobs: issues: write pull-requests: write steps: - # https://github.com/actions/first-interaction - uses: actions/first-interaction@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} From 75e0070c59e4116d8b6e2ccee33c8001174dce42 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 10:44:38 +0530 Subject: [PATCH 04/29] manual trigger --- .github/workflows/multi-event.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/workflows/multi-event.yml diff --git a/.github/workflows/multi-event.yml b/.github/workflows/multi-event.yml deleted file mode 100644 index a3275be3..00000000 --- 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 From ec00561c5d3750de221062d27aa50a0159129789 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 10:45:40 +0530 Subject: [PATCH 05/29] added: manual workflow --- .github/workflows/manual.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/manual.yml diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 00000000..081adf3a --- /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 From d425a6b1eacf389f184e068759e015a211652b1b Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 11:05:01 +0530 Subject: [PATCH 06/29] workflow run --- .github/workflows/schedule.yml | 10 ---------- github-actions/Readme.me | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 .github/workflows/schedule.yml diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml deleted file mode 100644 index a88231de..00000000 --- a/.github/workflows/schedule.yml +++ /dev/null @@ -1,10 +0,0 @@ -on: - schedule: - - cron: '*/5 * * * *' - -jobs: - hello_world: - runs-on: ubuntu-latest - steps: - - name: Echo current time - run: echo "The current server time is $(date)" diff --git a/github-actions/Readme.me b/github-actions/Readme.me index 9be613aa..c2a6503c 100644 --- a/github-actions/Readme.me +++ b/github-actions/Readme.me @@ -1,8 +1,8 @@ ## Manual Trigger ```sh -gh workflow run greet.yml -f name=mona -f greeting=hello -F data=@myfile.txt -echo '{"name":"mona", "greeting":"hello"}' | gh workflow run greet.yml --json +gh workflow run manual.yml -f name=mona -f greeting=hello -F data=@data +echo '{"name":"mona", "greeting":"hello"}' | gh workflow run manual.yml --json ``` ## Webhook Event From 6eda110dfa7552d62c988f11e32eb077e99bc4cd Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 15:52:20 +0530 Subject: [PATCH 07/29] workflow/webhook --- .github/workflows/custom-action.yml | 15 -------------- .github/workflows/manual.yml | 32 ----------------------------- 2 files changed, 47 deletions(-) delete mode 100644 .github/workflows/custom-action.yml delete mode 100644 .github/workflows/manual.yml diff --git a/.github/workflows/custom-action.yml b/.github/workflows/custom-action.yml deleted file mode 100644 index 7a87b53f..00000000 --- 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/manual.yml b/.github/workflows/manual.yml deleted file mode 100644 index 081adf3a..00000000 --- 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 From 4f1b4121aa0095f0580bc32cb4c512a2b4878be6 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 15:53:28 +0530 Subject: [PATCH 08/29] workflow/webhook --- .github/workflows/webhook.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/webhook.yml diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml new file mode 100644 index 00000000..dbdf1e47 --- /dev/null +++ b/.github/workflows/webhook.yml @@ -0,0 +1,15 @@ +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" From 1ef784f473b062fb69f33fa5a06f47e661b545d0 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:02:40 +0530 Subject: [PATCH 09/29] workflow/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 dbdf1e47..b200d991 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 + - name: Checkout repo uses: actions/checkout@v2 - name: Run a script run: echo "Event of type: $GITHUB_EVENT_NAME" From 6d01029c6677c55bca382ebebf690e9185bd404c Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:04:57 +0530 Subject: [PATCH 10/29] fix spacing --- .github/workflows/webhook.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index b200d991..5c07921a 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -5,6 +5,7 @@ on: types: - webhook + jobs: respond-to-dispatch: runs-on: ubuntu-latest From d2b41e51c78de0422a932dc95391d9e34c6e2e17 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:14:49 +0530 Subject: [PATCH 11/29] added : shell bash --- .github/workflows/webhook.yml | 3 ++- github-actions/Readme.me | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index 5c07921a..0f9ce7aa 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -5,7 +5,6 @@ on: types: - webhook - jobs: respond-to-dispatch: runs-on: ubuntu-latest @@ -14,3 +13,5 @@ jobs: uses: actions/checkout@v2 - name: Run a script run: echo "Event of type: $GITHUB_EVENT_NAME" + shell: bash + \ No newline at end of file diff --git a/github-actions/Readme.me b/github-actions/Readme.me index c2a6503c..f586504f 100644 --- a/github-actions/Readme.me +++ b/github-actions/Readme.me @@ -12,5 +12,10 @@ curl -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token {PAT} \ -d '{"event_type": "webhook", "client_payload": {"key": "value"} }' \ -https://api.github.com/repos/{owner}/{repo}/dispatches -``` \ No newline at end of file +https://api.github.com/repos/mehtachandrashekhar/Github-Example/dispatches +``` +curl -X POST \ +-H "Accept: application/vnd.github+json" \ +-H "Authorization: token {PAT} \ +-d '{"event_type": "webhook", "client_payload": {"key": "value"} }' \ +https://api.github.com/repos/mehtachandrashekhar/Github-Examples/dispatches \ No newline at end of file From aeaebe63df2edbf3c67a2ef935dc480b161e7a64 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:15:50 +0530 Subject: [PATCH 12/29] added : shell bash --- .github/workflows/webhook.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml index 0f9ce7aa..00d2a24f 100644 --- a/.github/workflows/webhook.yml +++ b/.github/workflows/webhook.yml @@ -12,6 +12,4 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: Run a script - run: echo "Event of type: $GITHUB_EVENT_NAME" - shell: bash - \ No newline at end of file + run: echo "Event of type: ${{ github.event_name }}" From 6c4d3751ce181b67a213df9b0a7683ac156723a3 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:24:43 +0530 Subject: [PATCH 13/29] added : don't trigger --- .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 00d2a24f..4a08b0ad 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 }}" From 2f02c0f9c18db43264b6fb5532902eb27783edc3 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:31:49 +0530 Subject: [PATCH 14/29] removed:tokens --- github-actions/Readme.me | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/github-actions/Readme.me b/github-actions/Readme.me index f586504f..8b2bbcfe 100644 --- a/github-actions/Readme.me +++ b/github-actions/Readme.me @@ -13,9 +13,4 @@ curl -X POST \ -H "Authorization: token {PAT} \ -d '{"event_type": "webhook", "client_payload": {"key": "value"} }' \ https://api.github.com/repos/mehtachandrashekhar/Github-Example/dispatches -``` -curl -X POST \ --H "Accept: application/vnd.github+json" \ --H "Authorization: token {PAT} \ --d '{"event_type": "webhook", "client_payload": {"key": "value"} }' \ -https://api.github.com/repos/mehtachandrashekhar/Github-Examples/dispatches \ No newline at end of file +``` \ No newline at end of file From c3280551c19d162b86baca876429519c80d7c58e Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:40:57 +0530 Subject: [PATCH 15/29] workflow/conditionals --- .github/workflows/webhook.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/workflows/webhook.yml diff --git a/.github/workflows/webhook.yml b/.github/workflows/webhook.yml deleted file mode 100644 index 4a08b0ad..00000000 --- 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 }}" From 7c4468f5cc5fe73eb41a65f234610163aa3be7ae Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:41:31 +0530 Subject: [PATCH 16/29] workflow/conditionals --- .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 00000000..87b48c2f --- /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 1d9c978aed8e389e6b15f0366d82e2551b26f8f8 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:55:23 +0530 Subject: [PATCH 17/29] workflow/expression --- .github/workflows/conditional.yml | 14 -------- .github/workflows/expression-functions.yml | 37 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 14 deletions(-) delete mode 100644 .github/workflows/conditional.yml create mode 100644 .github/workflows/expression-functions.yml diff --git a/.github/workflows/conditional.yml b/.github/workflows/conditional.yml deleted file mode 100644 index 87b48c2f..00000000 --- a/.github/workflows/conditional.yml +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml new file mode 100644 index 00000000..9bc66c3c --- /dev/null +++ b/.github/workflows/expression-functions.yml @@ -0,0 +1,37 @@ +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() }} + - name: The job has failed + if: ${{ failure() }} \ No newline at end of file From 9c2d24e7324af9e601841a590f447c5f43241c59 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:56:09 +0530 Subject: [PATCH 18/29] workflow/expression --- .github/workflows/expression-functions.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index 9bc66c3c..c6a91553 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -4,8 +4,6 @@ on: push: branches: - main - issues: - types: [opened, labeled] jobs: expression-functions: From 27e472cd0d62c503e62d5746d1dd544796ff541b Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:57:37 +0530 Subject: [PATCH 19/29] workflow/expression --- .github/workflows/expression-functions.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index c6a91553..98dcec0f 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -32,4 +32,6 @@ jobs: - name: The job has succeeded if: ${{ success() }} - name: The job has failed - if: ${{ failure() }} \ No newline at end of file + if: ${{ failure() }} + - name: "goodbye" + run: "not a valid input" \ No newline at end of file From af5a43a73726bca912e69958ad36e1f4f70f7292 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:59:02 +0530 Subject: [PATCH 20/29] workflow/expression --- .github/workflows/expression-functions.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index 98dcec0f..a4d832d6 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -33,5 +33,4 @@ jobs: if: ${{ success() }} - name: The job has failed if: ${{ failure() }} - - name: "goodbye" - run: "not a valid input" \ No newline at end of file + run: "failed to do job" \ No newline at end of file From be88cfa61dfd64580438096de03eddf9bbb7a4ed Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 16:59:25 +0530 Subject: [PATCH 21/29] workflow/expression --- .github/workflows/expression-functions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index a4d832d6..7dc11121 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -33,4 +33,4 @@ jobs: if: ${{ success() }} - name: The job has failed if: ${{ failure() }} - run: "failed to do job" \ No newline at end of file + run: echo "failed to do job" \ No newline at end of file From 5ad729e9a3c688a21662594ec9a6309553920ca9 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 17:01:05 +0530 Subject: [PATCH 22/29] workflow/expression --- .github/workflows/expression-functions.yml | 69 +++++++++++----------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml index 7dc11121..62b6c575 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -1,36 +1,37 @@ -name: Expression Functions Demo + name: Expression Functions Demo -on: - push: - branches: - - main + on: + push: + branches: + - main -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() }} - - name: The job has failed - if: ${{ failure() }} - run: echo "failed to do job" \ No newline at end of file + 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 "this job is succes" + - name: The job has failed + if: ${{ failure() }} + run: echo "failed to do job" \ No newline at end of file From a385d43cbce34327ba88f4adcd5cfa21f0235858 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 17:04:13 +0530 Subject: [PATCH 23/29] workflow/expression --- .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 62b6c575..fe8d6499 100644 --- a/.github/workflows/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -28,9 +28,9 @@ - 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') }} + run: echo "Hash of files:${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }}" - name: The job has succeeded - if: ${{ success() }} + if: ${{ success() }} run: echo "this job is succes" - name: The job has failed if: ${{ failure() }} From f11ff8911a0c585c853f916ab8ed6f0e2ed98a46 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 17:19:18 +0530 Subject: [PATCH 24/29] runner for mac/windows os --- .github/workflows/expression-functions.yml | 37 --------------------- .github/workflows/runner-macos.yml | 30 +++++++++++++++++ .github/workflows/runner-windows.yml | 38 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/expression-functions.yml create mode 100644 .github/workflows/runner-macos.yml create mode 100644 .github/workflows/runner-windows.yml diff --git a/.github/workflows/expression-functions.yml b/.github/workflows/expression-functions.yml deleted file mode 100644 index fe8d6499..00000000 --- a/.github/workflows/expression-functions.yml +++ /dev/null @@ -1,37 +0,0 @@ - name: Expression Functions Demo - - on: - push: - branches: - - main - - 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 "this job is succes" - - name: The job has failed - if: ${{ failure() }} - run: echo "failed to do job" \ No newline at end of file diff --git a/.github/workflows/runner-macos.yml b/.github/workflows/runner-macos.yml new file mode 100644 index 00000000..6baa5adf --- /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-windows.yml b/.github/workflows/runner-windows.yml new file mode 100644 index 00000000..3b73f2b2 --- /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 From d21551f5ec6fe526cefca52630e7b28b7753e794 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 18:04:17 +0530 Subject: [PATCH 25/29] workflow/commands --- .github/workflows/runner-macos.yml | 30 -------------------- .github/workflows/runner-windows.yml | 38 -------------------------- .github/workflows/workflow-command.yml | 14 ++++++++++ 3 files changed, 14 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/runner-macos.yml delete mode 100644 .github/workflows/runner-windows.yml create mode 100644 .github/workflows/workflow-command.yml diff --git a/.github/workflows/runner-macos.yml b/.github/workflows/runner-macos.yml deleted file mode 100644 index 6baa5adf..00000000 --- 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 3b73f2b2..00000000 --- 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 diff --git a/.github/workflows/workflow-command.yml b/.github/workflows/workflow-command.yml new file mode 100644 index 00000000..14d3061e --- /dev/null +++ b/.github/workflows/workflow-command.yml @@ -0,0 +1,14 @@ + name: "workflow-commands" + + on: ['push'] + + jobs: + my-job: + runs-on: ubuntu-latest + steps: + - name: "group loggging" + runs: | + echo: "::group:: My group message" + echo: "Msg1" + echo: "Msg1" + echo: "::endgroup::" From e6cd8b121a5ca2b936d01b58a021d9d8c37801e0 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Sun, 9 Jun 2024 18:08:43 +0530 Subject: [PATCH 26/29] workflow/commands --- .github/workflows/workflow-command.yml | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/workflow-command.yml b/.github/workflows/workflow-command.yml index 14d3061e..fe7c7ff6 100644 --- a/.github/workflows/workflow-command.yml +++ b/.github/workflows/workflow-command.yml @@ -1,14 +1,14 @@ - name: "workflow-commands" - - on: ['push'] - - jobs: - my-job: - runs-on: ubuntu-latest - steps: - - name: "group loggging" - runs: | - echo: "::group:: My group message" - echo: "Msg1" - echo: "Msg1" - echo: "::endgroup::" +name: "workflow-commands" + +on: ['push'] + +jobs: + my-job: + runs-on: ubuntu-latest + steps: + - name: "group logging" + run: | + echo "::group:: My group message" + echo "Msg1" + echo "Msg2" + echo "::endgroup::" From d6ef05197b7fce946b994fb52628a8a462229d03 Mon Sep 17 00:00:00 2001 From: Chandrashekhar <67406458+mehtachandrashekhar@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:12:05 +0530 Subject: [PATCH 27/29] Create label.yml --- .github/workflows/label.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/label.yml diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 00000000..46135690 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,22 @@ +# This workflow will triage pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler + +name: Labeler +on: [pull_request_target] + +jobs: + label: + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From 9bc1e2c1c42e04241062281eecb99606682c4ba5 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Mon, 10 Jun 2024 20:20:57 +0530 Subject: [PATCH 28/29] workflow/context.yml --- .github/workflows/context.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/context.yml diff --git a/.github/workflows/context.yml b/.github/workflows/context.yml new file mode 100644 index 00000000..5edf97ce --- /dev/null +++ b/.github/workflows/context.yml @@ -0,0 +1,12 @@ +name: Context Examples + +on: ['push'] + +jobs: + my-context: + runs-on: ubuntu-latest + steps: + - name: "My step" + run: echo "Hello $MY_ACTION" + env: + MY_ACTION: ${{github.action}} \ No newline at end of file From 929c0425c83ca8fd2dea917a2123c3ac82ca7876 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Date: Mon, 10 Jun 2024 20:49:34 +0530 Subject: [PATCH 29/29] workflow/jobs --- .github/workflows/context.yml | 12 ------------ .github/workflows/jobs.yml | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) delete mode 100644 .github/workflows/context.yml create mode 100644 .github/workflows/jobs.yml diff --git a/.github/workflows/context.yml b/.github/workflows/context.yml deleted file mode 100644 index 5edf97ce..00000000 --- a/.github/workflows/context.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Context Examples - -on: ['push'] - -jobs: - my-context: - runs-on: ubuntu-latest - steps: - - name: "My step" - run: echo "Hello $MY_ACTION" - env: - MY_ACTION: ${{github.action}} \ No newline at end of file diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml new file mode 100644 index 00000000..78256d7e --- /dev/null +++ b/.github/workflows/jobs.yml @@ -0,0 +1,17 @@ +name: "Jobs Examples" + +on: ['push'] + +jobs: + job2: + runs-on: ubuntu-latest + needs: job1 + steps: + - name: stepA + run: echo "Hello world" + + job1: + runs-on: ubuntu-latest + steps: + - name: stepB + run: echo "Hello job 2" \ No newline at end of file