|
| 1 | +--- |
| 2 | +engine: knitr |
| 3 | +title: Deployments and Code Promotion |
| 4 | +--- |
| 5 | + |
| 6 | +## Learning objectives |
| 7 | + |
| 8 | +- How--and why--progressively promote code from your computer to the cloud |
| 9 | +- Why work in 3 environments |
| 10 | +- How deployment can be automated with GitHub Actions |
| 11 | + |
| 12 | +## CI/CD: Find out what it means to me |
| 13 | + |
| 14 | +- <details> |
| 15 | + <summary>**Centralized, version-controlled source code builds the project.**</summary> |
| 16 | + - Not just on my machine. |
| 17 | + - No time-stamped versions. |
| 18 | + - No manual or non-code actions. |
| 19 | +</details> |
| 20 | +- <details> |
| 21 | + <summary>**Regular and "right-sized" changes to the code.**</summary> |
| 22 | + - No long-lived branches |
| 23 | + - No massive changes |
| 24 | +</details> |
| 25 | +- <details> |
| 26 | + <summary>**Automated pre-deployment tests.**</summary> |
| 27 | + - Ensure code meets standards (e.g., style, tests, etc.) |
| 28 | + - Break tests; not prod. |
| 29 | +</details> |
| 30 | +- <details> |
| 31 | + <summary>**Automated deployment**</summary> |
| 32 | + - No manually moving files |
| 33 | + - No making ad hoc changes as deployment is done |
| 34 | +</details> |
| 35 | + |
| 36 | +## Three envs for developer-kings 👑👑👑 |
| 37 | + |
| 38 | +:::: {.columns} |
| 39 | + |
| 40 | +::: {.column width="70%"} |
| 41 | + |
| 42 | +{fig-align="center"} |
| 43 | + |
| 44 | +::: |
| 45 | + |
| 46 | +::: {.column width="30%"} |
| 47 | + |
| 48 | +### Dev |
| 49 | + |
| 50 | +Where the messy magic happens |
| 51 | + |
| 52 | +### Test |
| 53 | + |
| 54 | +Where testing and scruntinization happen |
| 55 | + |
| 56 | +### Prod |
| 57 | + |
| 58 | +Where production code lives |
| 59 | + |
| 60 | +::: |
| 61 | + |
| 62 | +:::: |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +## One process to rule them all, and in the promotion bind them 💍 |
| 67 | + |
| 68 | +{fig-align="center"} |
| 69 | + |
| 70 | +## Environmental science: keeping envs separate but similar |
| 71 | + |
| 72 | +:::: {.columns} |
| 73 | + |
| 74 | +::: {.column width="50%"} |
| 75 | + |
| 76 | +### Challenge |
| 77 | + |
| 78 | +- If I have 3 envs, how do I keep them in sync? |
| 79 | +- If only prod can touch real data, how can I be sure changes in dev and test work? |
| 80 | + |
| 81 | +::: |
| 82 | + |
| 83 | +::: {.column width="50%" .fragment} |
| 84 | + |
| 85 | +### How |
| 86 | + |
| 87 | +- Branches |
| 88 | +- Configuration |
| 89 | +- Promotion |
| 90 | + |
| 91 | + |
| 92 | +::: |
| 93 | + |
| 94 | +:::: |
| 95 | + |
| 96 | + |
| 97 | +## Branches |
| 98 | + |
| 99 | +{fig-align="center"} |
| 100 | + |
| 101 | +## Configuration |
| 102 | + |
| 103 | +:::: {.columns} |
| 104 | + |
| 105 | +::: {.column width="50%"} |
| 106 | + |
| 107 | +### Either hand-roll a config per env ... |
| 108 | + |
| 109 | +Sorry--too lazy |
| 110 | + |
| 111 | +::: |
| 112 | + |
| 113 | +::: {.column width="50%" .fragment} |
| 114 | + |
| 115 | +### ... or make an env-aware config |
| 116 | + |
| 117 | +```yaml |
| 118 | +dev: |
| 119 | + write: false |
| 120 | + db-path: dev-db |
| 121 | +prod: |
| 122 | + write: true |
| 123 | + db-path: prod-db |
| 124 | +``` |
| 125 | +
|
| 126 | +::: |
| 127 | +
|
| 128 | +:::: |
| 129 | +
|
| 130 | +## Promotion |
| 131 | +
|
| 132 | +- Run tests |
| 133 | +- Review code |
| 134 | +- Merge |
| 135 | +
|
| 136 | +## Deployment: we've got a runner 🏃♂️➡️ |
| 137 | +
|
| 138 | +- Event listener (`on: ...`) |
| 139 | +- Job(s) |
| 140 | + - In an env |
| 141 | + - OS (`runs-on: ubuntu-latest`) |
| 142 | + - Env vars (e.g. `env: GITHUB_PAT: ${{ secrets.ACTIONS_DEPLOY_KEY }}`) |
| 143 | + - Consist of step(s) |
| 144 | + - Action (`uses`) |
| 145 | + - Command (`sudo make-coffee`) |
0 commit comments