13 files+108−250/13 viewed
| 1 | − | on: issue.exploded | |
| 2 | − | do: [assign_agent] |
| 1 | − | name: Label on every update | |
| 2 | − | on: [issue.updated, issue.opened] | |
| 3 | − | if: | |
| 4 | − | labels: automation-test | |
| 5 | − | do: | |
| 6 | − | - label: touched-again | |
| 7 | − | - comment: "Touched by {{automation}} after {{event}}." |
| 1 | − | on: manual | |
| 2 | − | do: | |
| 3 | − | - comment: "Run by hand on #{{number}} ({{title}})." |
| 1 | − | name: Triage test issues | |
| 2 | − | on: issue.opened | |
| 3 | − | if: | |
| 4 | − | labels: automation-test | |
| 5 | − | do: | |
| 6 | − | - comment: "Thanks, {{actor}}. This automation saw #{{number}} ({{title}}) and labelled it." | |
| 7 | − | - label: triaged | |
| 8 | − | - notify: | |
| 9 | − | url: https://httpbin.org/post | |
| 10 | − | text: "{{repo}}#{{number}} was triaged: {{url}}" |
| 1 | + | name: Caller | |
| 2 | + | on: | |
| 3 | + | workflow_dispatch: | |
| 4 | + | jobs: | |
| 5 | + | greet: | |
| 6 | + | uses: ./.github/workflows/reusable-greet.yml | |
| 7 | + | with: | |
| 8 | + | who: g1t | |
| 9 | + | loud: true | |
| 10 | + | report: | |
| 11 | + | needs: greet | |
| 12 | + | runs-on: ubuntu-latest | |
| 13 | + | steps: | |
| 14 | + | - run: echo "reusable said ${{ needs.greet.outputs.message }} (${{ needs.greet.result }})" |
| 1 | 1 | name: Checks | |
| 2 | 2 | on: | |
| 3 | 3 | pull_request: | |
| 4 | + | merge_group: | |
| 4 | 5 | push: | |
| 5 | 6 | branches: [main] | |
| 6 | 7 | jobs: |
| 1 | + | name: Greet (reusable) | |
| 2 | + | on: | |
| 3 | + | workflow_call: | |
| 4 | + | inputs: | |
| 5 | + | who: | |
| 6 | + | type: string | |
| 7 | + | required: true | |
| 8 | + | loud: | |
| 9 | + | type: boolean | |
| 10 | + | default: false | |
| 11 | + | outputs: | |
| 12 | + | message: | |
| 13 | + | description: What was said | |
| 14 | + | value: ${{ jobs.say.outputs.said }} | |
| 15 | + | jobs: | |
| 16 | + | say: | |
| 17 | + | runs-on: ubuntu-latest | |
| 18 | + | outputs: | |
| 19 | + | said: ${{ steps.greet.outputs.said }} | |
| 20 | + | steps: | |
| 21 | + | - id: greet | |
| 22 | + | run: | | |
| 23 | + | msg="hello, ${{ inputs.who }}" | |
| 24 | + | if [ "${{ inputs.loud }}" = "true" ]; then msg="${msg^^}!"; fi | |
| 25 | + | echo "$msg" | |
| 26 | + | echo "said=$msg" >> "$GITHUB_OUTPUT" | |
| 27 | + | after: | |
| 28 | + | needs: say | |
| 29 | + | runs-on: ubuntu-latest | |
| 30 | + | steps: | |
| 31 | + | - run: echo "the greeting was ${{ needs.say.outputs.said }}" |
| 1 | + | name: Rust toolchain | |
| 2 | + | on: | |
| 3 | + | workflow_dispatch: | |
| 4 | + | jobs: | |
| 5 | + | check: | |
| 6 | + | runs-on: ubuntu-latest | |
| 7 | + | steps: | |
| 8 | + | - uses: dtolnay/rust-toolchain@stable | |
| 9 | + | with: | |
| 10 | + | components: rustfmt, clippy | |
| 11 | + | - uses: actions/cache@v6 | |
| 12 | + | with: | |
| 13 | + | path: | | |
| 14 | + | ~/.cargo/registry | |
| 15 | + | ~/.cargo/git | |
| 16 | + | key: cargo-${{ runner.os }}-demo | |
| 17 | + | - run: | | |
| 18 | + | cargo new --quiet /tmp/demo | |
| 19 | + | cd /tmp/demo | |
| 20 | + | cargo fmt --check | |
| 21 | + | cargo clippy --quiet -- -D warnings | |
| 22 | + | cargo test --quiet | |
| 23 | + | rustc --version |
| 4 | 4 | return a + b; | |
| 5 | 5 | } | |
| 6 | 6 | ||
| 7 | − | module.exports = { add }; | |
| 7 | + | /** Returns the product of a and b. */ | |
| 8 | + | function multiply(a, b) { | |
| 9 | + | return a * b; | |
| 10 | + | } | |
| 8 | 11 | ||
| 9 | 12 | /** Returns a minus b. */ | |
| 10 | 13 | function subtract(a, b) { | |
| 11 | 14 | return a - b; | |
| 12 | 15 | } | |
| 13 | 16 | ||
| 14 | − | module.exports.subtract = subtract; | |
| 17 | + | module.exports = { add, multiply, subtract }; |
| 1 | + | <!doctype html> | |
| 2 | + | <html lang="en"> | |
| 3 | + | <head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>automation-lab</title></head> | |
| 4 | + | <body style="font-family: system-ui; background: #121214; color: #ececf1; padding: 3rem"> | |
| 5 | + | <h1>automation-lab, on g1t.page</h1> | |
| 6 | + | <p id="api">Asking the Worker…</p> | |
| 7 | + | <script>fetch("/api").then((r) => r.json()).then((d) => (document.getElementById("api").textContent = JSON.stringify(d)));</script> | |
| 8 | + | </body> | |
| 9 | + | </html> |
| 1 | + | // /api says what this deployment was given; everything else is the site. | |
| 2 | + | export default { | |
| 3 | + | async fetch(request, env) { | |
| 4 | + | const url = new URL(request.url); | |
| 5 | + | if (url.pathname === "/api") { | |
| 6 | + | return Response.json({ | |
| 7 | + | fromConfig: env.FROM_CONFIG ?? null, | |
| 8 | + | greeting: env.GREETING ?? null, | |
| 9 | + | apiUrl: env.API_URL ?? null, | |
| 10 | + | // Only a prefix: enough to tell the test key from the live one. | |
| 11 | + | stripeKey: env.STRIPE_KEY ? `${env.STRIPE_KEY.slice(0, 8)}…` : null, | |
| 12 | + | }); | |
| 13 | + | } | |
| 14 | + | return env.ASSETS.fetch(request); | |
| 15 | + | }, | |
| 16 | + | }; |
| 3 | 3 | assert.strictEqual(math.subtract(5, 3), 2); | |
| 4 | 4 | ||
| 5 | 5 | assert.strictEqual(math.add(2, 3), 5); | |
| 6 | − | if (math.multiply) assert.strictEqual(math.multiply(4, 5), 20); | |
| 6 | + | assert.strictEqual(math.multiply(4, 5), 20); | |
| 7 | 7 | console.log("all tests passed"); |
| 1 | + | { | |
| 2 | + | // A small Workers app, to show g1t.page deploying one. | |
| 3 | + | "name": "automation-lab", | |
| 4 | + | "main": "src/index.js", | |
| 5 | + | "compatibility_date": "2026-09-26", | |
| 6 | + | "assets": { "directory": "public", "binding": "ASSETS" }, | |
| 7 | + | "vars": { "FROM_CONFIG": "set in wrangler.jsonc" } | |
| 8 | + | } |