-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1515 from opensafely/iaindillingham/how-to-add-co…
…despaces Add "How to add Codespaces to your project" page
- Loading branch information
Showing
4 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+1.25 KB
...ting-started/how-to/add-github-codespaces-to-your-project/download_raw_file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 126 additions & 0 deletions
126
docs/getting-started/how-to/add-github-codespaces-to-your-project/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
This page describes how to add GitHub Codespaces to your project. | ||
|
||
## Does your project already have GitHub Codespaces? | ||
|
||
Newer projects already have GitHub Codespaces. | ||
However, older projects don't. | ||
To find out whether your project is newer or older: | ||
|
||
* Click on your project in the [opensafely](https://github.com/opensafely) organisation on GitHub. | ||
* Can you see a `.devcontainer` folder? | ||
If not, then your project is **older**. | ||
* Click on the `.devcontainer` folder to open it. | ||
* Click on the `devcontainer.json` file to open it. | ||
* Can you see the following line towards the top of the file? | ||
If not, then your project is **older**. | ||
```json | ||
"image": "ghcr.io/opensafely-core/research-template:v0", | ||
``` | ||
* If you've got this far, then your project is **newer**. | ||
|
||
## Adding GitHub Codespaces to your project | ||
|
||
We will use Git to add GitHub Codespaces to your project. | ||
There are many ways to use Git. | ||
For example, we could use Git with the `git` command-line tool, with GitHub Desktop, or with VS Code. | ||
Here, we will use Git with `git`, because `git` commands are succinct. | ||
The documentation for | ||
[GitHub Desktop](https://docs.github.com/en/desktop) and | ||
[VS Code](https://code.visualstudio.com/docs/sourcecontrol/overview) | ||
describes how to translate `git` commands into equivalent user-interface commands. | ||
|
||
Here, you will run `git` commands on your computer. | ||
|
||
### Identify your project's working branch | ||
|
||
The *working branch* contains work that is "done". | ||
It is often called `main` and it is often associated with a workspace on OS Jobs. | ||
|
||
We will add GitHub Codespaces to the working branch. | ||
|
||
### Create a new branch | ||
|
||
Switch to the working branch: | ||
|
||
```sh | ||
git switch <working branch> | ||
``` | ||
|
||
Create a new branch called `github-codespaces`: | ||
|
||
```sh | ||
git switch --create=github-codespaces | ||
``` | ||
|
||
### Copy files | ||
|
||
* Visit the [opensafely/research-template](https://github.com/opensafely/research-template) project on GitHub. | ||
* Click on the `.devcontainer` folder to open it. | ||
* Click on the first file to open it. | ||
* Click on "Download raw file" (![The "Download raw file" icon](download_raw_file.png)) to download the first file to your computer. | ||
* Repeat for the remaining files. | ||
* Copy each file to the `.devcontainer` folder in your project. | ||
|
||
!!! info "My project doesn't have a `.devcontainer` folder" | ||
If your project doesn't have a `.devcontainer` folder, | ||
then create one. | ||
It's important that it starts with a dot (`.`). | ||
|
||
### Commit and push | ||
|
||
Commit the files you copied in the previous step: | ||
|
||
```sh | ||
git commit --message='Add GitHub Codespaces' | ||
``` | ||
|
||
Push to GitHub: | ||
|
||
```sh | ||
git push | ||
``` | ||
|
||
### Create a pull request | ||
|
||
* Click on your project in the [opensafely](https://github.com/opensafely) organisation on GitHub. | ||
* Click on "Pull requests". | ||
* Click on "New pull request". | ||
* Beneath "Compare changes" there are two boxes labelled "base" and "compare". | ||
* The "base" box should contain the name of the working branch. | ||
* The "compare" box should contain `github-codespaces`. | ||
* Click on "Create pull request". | ||
|
||
### Approve and merge the pull request | ||
|
||
* Click on "Files changed" | ||
* Click on "Review changes" | ||
* Click on "Approve" | ||
* Click on "Submit review" | ||
* Click on "Merge pull request" | ||
|
||
### Housekeeping | ||
|
||
Switch to the working branch: | ||
|
||
```sh | ||
git switch <working branch> | ||
``` | ||
|
||
Pull from GitHub: | ||
|
||
```sh | ||
git pull | ||
``` | ||
|
||
Delete the `github-codespaces` branch: | ||
|
||
```sh | ||
git branch --delete github-codespaces | ||
``` | ||
|
||
### Start a Codespace | ||
|
||
The | ||
"[How to use GitHub Codespaces in your project](../use-github-codespaces-in-your-project/index.md)" | ||
page has more information about using GitHub Codespaces in your project, | ||
including how to start a Codespace :rocket:. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters