# Teaching guide · Session 5 — From repository to deployment

## 1. Goal and limits

Learners arrive from S4 with a reviewed, integrated change. In S5 they prepare repeatable publishing with GitHub Actions and clasp: **manual first, then automatic if they choose**. They must distinguish spreadsheet, Apps Script project, version and deployment, and verify the same /exec after publishing.

Do not present “merge = deploy” as unconditional. A push can trigger a configured workflow; permissions, upload or deployment update may still fail. A green job does not validate the app’s logic or access either.

## 2. Teaching preparation

Rehearse the [S5 kit guide](../../kit-desplegament-s5.en.html) with a **practice project**, fictional data and an existing private deployment. Identify the three IDs separately. Do not use a business app in service as the first test.

The kit accepts only Codi.gs, Index.html and appsscript.json at the root, the S1 ID_DEL_FULL marker and the original V8 manifest. If there are more files or other names, adapt the plan before publishing: do not delete content to fit. Upload may replace the entire remote project and may stop partway.

Prepare:

- An authorised private repo, Actions availability, checked permissions and quotas; no implicit purchases or visibility changes.
- Node 24 and the kit with clasp 3.4.1, package-lock and actions pinned to commits. The guide explains installing and authorising the correct version.
- A trusted OAuth environment. Each person authorises their account and enters the credential directly into the secret; it is not projected or shared with AI or the teacher.
- SCRIPT_ID, DEPLOYMENT_ID and SPREADSHEET_ID variables. Leave AUTO_DEPLOY empty until manual publishing is tested.
- A sanitised log and recorded demonstration or diagram if account policy blocks OAuth or the API. This supports analysis, but does not prove a real deployment.
- The previous version recorded and a separate data backup. Rehearse recovery in the practice project.

## 3. Suggested 150-minute route

| Time | Activity | Evidence |
|---|---|---|
| 0–20 min | Resume S4 and distinguish destinations | Spreadsheet, Script ID, Deployment ID and /exec identified |
| 20–45 min | Read the AI plan and compare it with the kit | Files, manifest, versions and limits reviewed |
| 45–70 min | Prepare authorisation, variables and secret outside chat | Configuration confirmed without showing values |
| 70–90 min | Reviewed PR and first manual run on main | Commit and job identified |
| 90–115 min | Check the same /exec and access | Valid record, rejected input and correct spreadsheet |
| 115–135 min | Analyse an error and recovery | Affected stage, remote state and previous version |
| 135–150 min | Decide automation and protections | Worksheet with results, pending work and next step |

Do not rush consent or review to meet the schedule. Automation is optional. An unperformed external test remains pending with its reason; do not mark it checked.

## 4. What the kit checks and what it does not

The deployer checks environment, IDs, clasp version, inventory, backend and inline-script syntax, manifest and remote spreadsheet. After push it downloads and compares files, creates a version and updates the same deployment. It removes temporary files and the credential it created. It does not use clasp force push.

Automated tests **simulate** clasp responses, including errors and no-op uploads. They prove neither OAuth nor a real Google deployment. They also do not test every feature, integration, permission or business case. Keep S1/S2 tests and add manual verification at the same /exec.

| Sticking point | Diagnostic guidance |
|---|---|
| Login or API denied | Account, consent, API, credential and policies. Do not bypass restrictions |
| Missing secret or variable | Compare names and scopes with the workflow; never print the credential |
| Different inventory or manifest | Stop; export and review the complete project before adapting |
| Green job, old app | Confirm deployment ran, SHA, version, ID and same /exec |
| Failure after push | Editor code may have changed; inspect state before retrying |
| Re-run still fails after a fix | It uses the original commit; identify the new run corresponding to the change |
| Protection unavailable in private repo | Review plan and effective rules; keep manual publishing without making it public |

## 5. Review, secrets and teamwork

The **s5.setup** and **s5.actionDebug** prompts ask for a reviewable plan and a diagnosis using sanitised information. They do not authorise an agent to create secrets, change rules or publish. Review the workflow as code capable of using credentials.

With AUTO_DEPLOY=true, any permitted push to main may trigger publishing. Private branch protections require a compatible plan and may have administrator exceptions. Do not promise a rule can never be bypassed. With one person, do not require formal self-approval of a PR: GitHub does not allow it.

The team challenge is optional: roles and review in a practice repo. Without effective rules, a manual workflow is valid. Do not use pull_request_target to run unreviewed code with secrets.

## 6. Recovery and closing

During an incident, clear AUTO_DEPLOY and check active or queued runs. Select the previous version of the same deployment in Apps Script and test the same /exec. Also fix the repository through a PR so another publication cannot reintroduce the error. Recovering code does not undo spreadsheet writes.

Ask for an explanation of the route: **commit → workflow → push → version → deployment → app test**. Review the worksheet: what was checked with Google, what was only simulated and what remains pending. The seven steps and existing checkboxes are preserved.

## Materials and sources

- [Interactive session](../../../sessio_5/codi/sessio5.en.html), [kit guide](../../kit-desplegament-s5.en.html) and [test worksheet](../../fitxa-proves-s4-s5.en.html).
- [Prompt bank](../../banc-de-prompts.en.html), [FAQ](../../faq-alumne.en.html) and [cheat sheets](../../chuletes.en.html).
- [clasp 3.4.1](https://github.com/google/clasp/blob/v3.4.1/README.md), [Apps Script deployments](https://developers.google.com/apps-script/concepts/deployments) and [GitHub branch protection](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches).

Reviewed on 2026-10-26. The HTML is generated from this Markdown; links target the website’s resources folder.
