Skip to content

Commit 6cfc3a1

Browse files
Make primary branch main, update deploy docs for GitHub Actions
1 parent aa8ffd1 commit 6cfc3a1

File tree

4 files changed

+53
-26
lines changed

4 files changed

+53
-26
lines changed

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = class AddonDocsConfig {
1111
}
1212

1313
getPrimaryBranch() {
14-
return 'master';
14+
return 'main';
1515
}
1616

1717
getRootURL() {

tests/dummy/app/templates/docs/deploying.md

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ Note that this only applies to non-prerelease tags, so `v1.2.3` would update the
5252

5353
When you deploy from a commit at the head of a branch that _doesn't_ have a tag associated with it, the compiled app will land in a folder named after that branch, as in our "getting started" example above. Unlike tag deploys, branch deploys will never automatically update the root app.
5454

55-
The main use case for branch deploys is tracking development work since your last stable release. If you run `ember deploy` after successful builds on `master`, you'll always have documentation available for the bleeding edge of your addon's features. Since branch deploys don't update the root, though, developers looking at your docs will still hit your most recent stable tag by default, so there won't be any confusion about things that have drifted since the last release.
55+
The main use case for branch deploys is tracking development work since your last stable release. If you run `ember deploy` after successful builds on `main`, you'll always have documentation available for the bleeding edge of your addon's features. Since branch deploys don't update the root, though, developers looking at your docs will still hit your most recent stable tag by default, so there won't be any confusion about things that have drifted since the last release.
5656

5757
## Automating deploys
5858

59-
While you _can_ just run `ember deploy production` yourself after every commit to `master` and each new release of your addon, you can simplify life a bit by automating the process as part of your CI setup. The process described here details the configuration for [Travis CI](https://travis-ci.org/), which Ember addons are configured to work with out of the box, but the setup should be very similar for other CI providers.
59+
While you _can_ just run `ember deploy production` yourself after every commit to `main` and each new release of your addon, you can simplify life a bit by automating the process as part of your CI setup. The process described here details the configuration for GitHub Actions, which Ember addons are configured to work with out of the box, but the setup should be very similar for other CI providers.
6060

6161
### Generate a deploy key
6262

@@ -76,41 +76,64 @@ On GitHub, open the page for your repo and navigate to _Settings_ -> _Deploy key
7676

7777
Enter a name for your key and then paste the contents of your public key (`deploy_key.pub`) into the big textarea. Make sure you check the **Allow write access** box, then click "Add key" and you're all set.
7878

79-
### Configure the private key with Travis
79+
### Configure the private key with GitHub Actions
8080

81-
Now that GitHub knows that this public key is allowed to push commits to your repo, we need to set up Travis to use the corresponding private key. Because the keyfile contains newlines, the easiest way to do this is using the [Travis CLI](https://github.com/travis-ci/travis.rb#installation) tool.
81+
Now that GitHub knows that this public key is allowed to push commits to your repo, we need to set up GitHub Actions to use the corresponding private key.
82+
83+
You can copy your private key by running the following:
8284

8385
```sh
84-
travis env set -- DEPLOY_KEY "$(cat deploy_key)"
86+
cat deploy_key | pbcopy
8587
```
8688

89+
Then you will need to go to the page for your repo and navigate to _Settings_ -> _Secrets and variables_ -> _Actions_ (or just directly visit <u>https://github.com/**[user]**/**[repo]**/settings/secrets/actions)</u> and click "New repository secret". The name should be `DEPLOY_KEY` and the value should be the private key you just copied.
90+
8791
### Deploy after successful builds
8892

89-
All that's left now is to set up Travis to run your deploys for you. The simplest way to do this is to add this `after_success` script to the end of your `.travis.yml`:
93+
All that's left now is to set up GitHub Actions to run your deploys for you. The simplest way to do this is to create a new file under `.github/workflows/addon-docs.yml` with the following contents:
9094

9195
```yml
92-
after_success:
93-
- if [[ ($TRAVIS_BRANCH == master || -n $TRAVIS_TAG) && $EMBER_TRY_SCENARIO == ember-default ]]; then
94-
node_modules/.bin/ember deploy production;
95-
fi
96+
name: Publish Addon Docs
97+
98+
on:
99+
push:
100+
branches:
101+
- main
102+
- master
103+
tags:
104+
- "**"
105+
jobs:
106+
build:
107+
env:
108+
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
109+
runs-on: ubuntu-latest
110+
steps:
111+
- uses: actions/checkout@v4
112+
with:
113+
token: ${{ secrets.GITHUB_TOKEN }}
114+
- uses: pnpm/action-setup@v4
115+
with:
116+
version: 9
117+
- uses: actions/setup-node@v4
118+
with:
119+
node-version: 18
120+
cache: pnpm
121+
- name: Install Dependencies
122+
run: pnpm install --no-lockfile
123+
- name: Deploy Docs
124+
run: |
125+
cd test-app
126+
pnpm ember deploy production
96127
```
97128
98-
Alternatively, if you're using Travis's [build stages system](https://docs.travis-ci.com/user/build-stages/), you can set up the deploy as a conditional stage at the end of your build:
99-
100-
```yml
101-
stages:
102-
# ...your other build stages...
103-
- name: deploy
104-
if: (branch = master or tag is present) and type = push
105-
script: node_modules/.bin/ember deploy production
106-
```
129+
This assumes you have a v2 addon and your addon docs are in the `test-app` folder, but if your addon docs are in a different location, you can change `test-app` to whatever that folder is and `cd` into it.
107130

108131
## Customizing deploys
109132

110133
When you install AddonDocs, a `config/addon-docs.js` file will automatically be created for you that looks something like this:
111134

112135
```js
113-
const AddonDocsConfig = require('ember-cli-addon-docs/lib/config');
136+
const AddonDocsConfig = require("ember-cli-addon-docs/lib/config");
114137
115138
module.exports = class extends AddonDocsConfig {
116139
// ...
@@ -145,7 +168,7 @@ If instead, however, you want to [set up a CNAME for your project](https://help.
145168

146169
### `getPrimaryBranch()`
147170

148-
This method determines what AddonDocs considers to be your primary branch, which is where links such as "edit this page" will point. By default, this branch is `master`, but you can override this method to choose a different branch instead, e.g. `develop`.
171+
This method determines what AddonDocs considers to be your primary branch, which is where links such as "edit this page" will point. By default, this branch is `main`, but you can override this method to choose a different branch instead, e.g. `develop`.
149172

150173
## Removing a deployed version
151174

@@ -178,8 +201,8 @@ If you wish to disable ember-cli-addon-docs' built-in deployment plugins altoget
178201
// ...
179202
ENV.pipeline = {
180203
disabled: {
181-
'ember-cli-addon-docs': true
182-
}
204+
"ember-cli-addon-docs": true,
205+
},
183206
};
184207
// ...
185208
```

tests/dummy/app/templates/docs/patterns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ AddonDocs provides versioned guides out of the box. You can see the version sele
6262

6363
If you look at the [`gh-pages`](https://github.com/ember-learn/ember-cli-addon-docs/tree/gh-pages) branch you'll see that this is where versioned builds of your docs app are stored. Versions are created at deploy time and AddonDocs manages this branch of your repository for you.
6464

65-
New versions are created when a new tag is released. There is also a `master` version updated on every deployed commit, and a `Latest` alias that points to the most recent tag, unless it is force-updated to point to `master`.
65+
New versions are created when a new tag is released. There is also a `main` version updated on every deployed commit, and a `Latest` alias that points to the most recent tag, unless it is force-updated to point to `main`.
6666

6767
See the next section on <DocsLink @route="docs.deploying">deploy guides</DocsLink> for more information about deploys.
6868

tests/dummy/config/addon-docs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33

44
const AddonDocsConfig = require('../../../lib/config');
55

6-
module.exports = class extends AddonDocsConfig {};
6+
module.exports = class extends AddonDocsConfig {
7+
getPrimaryBranch() {
8+
return 'master';
9+
}
10+
};

0 commit comments

Comments
 (0)