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/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 diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml new file mode 100644 index 000000000..4186413d9 --- /dev/null +++ b/.github/workflows/schedule.yml @@ -0,0 +1,10 @@ +on: + schedule: + - cron: '*/1 * * * *' + +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..e61ba0aea --- /dev/null +++ b/.github/workflows/webhook.yml @@ -0,0 +1,13 @@ +name: "Webhook Event example" + +on: + repository_dispatch: + types: + - webhook + +jobs: + respond-to-dispatch: + runs-on: ubuntu-latest + steps: + - name: "Run a script" + run: 'echo "Event of type: $GITHUB_EVENT_NAME"' diff --git a/README.md b/README.md index 43fc9143d..fc0302c36 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Github-Examples A repo containing GitHub for programmatic examples + \ No newline at end of file diff --git a/github-actions/Readme.me b/github-actions/Readme.me index 9be613aad..0e65f6767 100644 --- a/github-actions/Readme.me +++ b/github-actions/Readme.me @@ -1,7 +1,7 @@ ## Manual Trigger ```sh -gh workflow run greet.yml -f name=mona -f greeting=hello -F data=@myfile.txt +gh workflow run manual.yml -f name=mona -f greeting=hello -F data=@mydata echo '{"name":"mona", "greeting":"hello"}' | gh workflow run greet.yml --json ``` @@ -13,4 +13,12 @@ curl -X POST \ -H "Authorization: token {PAT} \ -d '{"event_type": "webhook", "client_payload": {"key": "value"} }' \ https://api.github.com/repos/{owner}/{repo}/dispatches +``` + +```sh +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/Sheane-mario/Github-Examples/dispatches ``` \ No newline at end of file diff --git a/.github/workflows/custom-action.yml b/github-actions/templates/custom-action.yml similarity index 100% rename from .github/workflows/custom-action.yml rename to github-actions/templates/custom-action.yml diff --git a/github-actions/templates/greetings.yml b/github-actions/templates/greetings.yml index 996da6bbd..086fdc5c1 100644 --- a/github-actions/templates/greetings.yml +++ b/github-actions/templates/greetings.yml @@ -1,6 +1,6 @@ name: Greetings -on: [pull_request_target, issues] +on: [pull_request_target, issues, push] jobs: greeting: @@ -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 }} diff --git a/github-actions/templates/webhook.yml b/github-actions/templates/webhook.yml index dbdf1e47d..b200d991f 100644 --- a/github-actions/templates/webhook.yml +++ b/github-actions/templates/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"