Skip to content

Commit bdd2afe

Browse files
Switch default primary branch to main, update docs from Travis to GitHub Actions (#1617)
* Start updating deploy docs * Update index.js * Revert "Start updating deploy docs" This reverts commit e646098. * Revert "Update index.js" This reverts commit 405bdf6. * Tweak deploy config * Make primary branch main, update deploy docs for GitHub Actions * Switch remaining master references to main
1 parent ab3ab29 commit bdd2afe

File tree

10 files changed

+77
-62
lines changed

10 files changed

+77
-62
lines changed

.github/workflows/ci-cd.yml

+9-16
Original file line numberDiff line numberDiff line change
@@ -122,32 +122,25 @@ jobs:
122122
deploy-app:
123123
name: Deploy app
124124
needs: [lint, test-addon-floating, test-addon-locked, test-compatibility]
125+
env:
126+
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
125127
runs-on: ubuntu-latest
126128
timeout-minutes: 7
127129
# Only run on pushes to the default branch
128-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
130+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
129131
steps:
130132
- name: Check out a copy of the repo
131-
uses: actions/checkout@v3
132-
133-
- name: Set up Git user
134-
run: |
135-
# Set up a Git user for committing
136-
git config --global user.name "GitHub Actions"
137-
git config --global user.email "[email protected]"
138-
139-
# Copy the Git Auth from the local config
140-
git config --global "http.https://github.com/.extraheader" \
141-
"$(git config --local --get http.https://github.com/.extraheader)"
142-
133+
uses: actions/checkout@v4
134+
with:
135+
token: ${{ secrets.GITHUB_TOKEN }}
143136
- name: Use Node.js ${{ env.NODE_VERSION }}
144-
uses: actions/setup-node@v3
137+
uses: actions/setup-node@v4
145138
with:
146139
node-version: ${{ env.NODE_VERSION }}
147140
cache: pnpm
148141

149142
- name: Install dependencies
150-
run: pnpm i --frozen-lockfile
143+
run: pnpm install --no-lockfile
151144

152145
- name: Deploy
153-
run: pnpm deploy
146+
run: pnpm ember deploy production

config/deploy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = function (deployTarget) {
44
let ENV = {
55
build: {},
66
git: {
7-
repo: 'https://github.com/ember-learn/ember-cli-addon-docs.git',
7+
repo: 'git@github.com:ember-learn/ember-cli-addon-docs.git',
88
},
99
};
1010

lib/config.js

+1-1
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() {

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
},
1616
"scripts": {
1717
"build": "ember build --environment=production",
18-
"deploy": "ember deploy production",
1918
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
2019
"lint:css": "stylelint \"**/*.css\"",
2120
"lint:css:fix": "concurrently \"npm:lint:css -- --fix\"",

tests/acceptance/sandbox/api/components-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module('Acceptance | Sandbox | API | components', function (hooks) {
3737

3838
assert.strictEqual(
3939
editThisPageLinkHref,
40-
'https://github.com/ember-learn/ember-cli-addon-docs/edit/master/tests/dummy/app/pods/sandbox/index/template.md',
40+
'https://github.com/ember-learn/ember-cli-addon-docs/edit/main/tests/dummy/app/pods/sandbox/index/template.md',
4141
);
4242
});
4343

@@ -61,7 +61,7 @@ module('Acceptance | Sandbox | API | components', function (hooks) {
6161

6262
assert.strictEqual(
6363
editThisPageLinkHref,
64-
'https://github.com/ember-learn/ember-cli-addon-docs/edit/master/packages/foo-bar/tests/dummy/app/pods/sandbox/index/template.md',
64+
'https://github.com/ember-learn/ember-cli-addon-docs/edit/main/packages/foo-bar/tests/dummy/app/pods/sandbox/index/template.md',
6565
);
6666
});
6767
});

tests/acceptance/version-selector-test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ module('Acceptance | Version selector test', function (hooks) {
4949
path: '',
5050
name: 'Latest',
5151
},
52-
master: {
52+
main: {
5353
sha: '53b73465d31925f26fd1f77881aefcaccce2915a',
5454
tag: null,
55-
path: 'master',
56-
name: 'master',
55+
path: 'main',
56+
name: 'main',
5757
},
5858
'v0.2.x': {
5959
sha: 'aca26720d930843dd084b508fce75b158ff0386e',
@@ -90,7 +90,7 @@ module('Acceptance | Version selector test', function (hooks) {
9090

9191
assert
9292
.dom('[data-test-id="version"]:nth-child(2)')
93-
.includesText('master', 'master is rendered secon');
93+
.includesText('main', 'main is rendered second');
9494
assert.dom('[data-test-id="version"]:nth-child(2)').includesText('53b73');
9595

9696
assert
@@ -113,11 +113,11 @@ module('Acceptance | Version selector test', function (hooks) {
113113
path: '',
114114
name: 'Latest',
115115
},
116-
master: {
116+
main: {
117117
sha: '53b73465d31925f26fd1f77881aefcaccce2915a',
118118
tag: null,
119-
path: 'master',
120-
name: 'master',
119+
path: 'main',
120+
name: 'main',
121121
},
122122
'v0.1.0': {
123123
sha: 'd752437850bc9833ea3e354095b501473b0420ae',
@@ -145,7 +145,7 @@ module('Acceptance | Version selector test', function (hooks) {
145145
.includesText('Latest', 'latest is rendered on second open');
146146
assert
147147
.dom('[data-test-id="version"]:nth-child(2)')
148-
.includesText('master', 'master is rendered on second open');
148+
.includesText('main', 'main is rendered on second open');
149149
});
150150

151151
module('with a custom primary branch configured', function (hooks) {
@@ -167,11 +167,11 @@ module('Acceptance | Version selector test', function (hooks) {
167167
path: '',
168168
name: 'Latest',
169169
},
170-
master: {
170+
main: {
171171
sha: '53b73465d31925f26fd1f77881aefcaccce2915a',
172172
tag: null,
173-
path: 'master',
174-
name: 'master',
173+
path: 'main',
174+
name: 'main',
175175
},
176176
develop: {
177177
sha: '53b73465d31925f26fd1f77881aefcaccce2915a',
@@ -201,7 +201,7 @@ module('Acceptance | Version selector test', function (hooks) {
201201

202202
assert
203203
.dom('[data-test-id="version"]:nth-child(3)')
204-
.includesText('master', 'other branches are rendered last');
204+
.includesText('main', 'other branches are rendered last');
205205
assert.dom('[data-test-id="version"]:nth-child(3)').includesText('53b73');
206206
});
207207
});

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

+46-23
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

+1-1
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/app/templates/docs/quickstart.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For both classic and native classes, install the [YUIDoc](http://yui.github.io/y
1616
ember install ember-cli-addon-docs-yuidoc
1717
```
1818

19-
You can see an example of <DocsLink @route="sandbox.api.item" @model="components/yuidoc-component">an autodocumented YUIDoc component</DocsLink> in the sandbox, and view its source [on GitHub](https://github.com/ember-learn/ember-cli-addon-docs/blob/master/sandbox/app/components/yuidoc-component.js).
19+
You can see an example of <DocsLink @route="sandbox.api.item" @model="components/yuidoc-component">an autodocumented YUIDoc component</DocsLink> in the sandbox, and view its source [on GitHub](https://github.com/ember-learn/ember-cli-addon-docs/blob/main/sandbox/app/components/yuidoc-component.js).
2020

2121
## 3. Add the docs routes
2222

@@ -133,7 +133,7 @@ Remember, the dummy site is a full Ember application and these components are ju
133133

134134
As you document the public objects in your addon, they'll automatically show up in the left-hand navigation of your `docs` route under the "API REFERENCE" section, assuming you added the `<DocsViewer/>` component.
135135

136-
Check out <DocsLink @route="sandbox">the sandbox</DocsLink> for an example addon with autogenerated API docs on the side. You can also take a look [at the code on GitHub](https://github.com/ember-learn/ember-cli-addon-docs/tree/master/sandbox) to see how these objects were documented.
136+
Check out <DocsLink @route="sandbox">the sandbox</DocsLink> for an example addon with autogenerated API docs on the side. You can also take a look [at the code on GitHub](https://github.com/ember-learn/ember-cli-addon-docs/tree/main/sandbox) to see how these objects were documented.
137137

138138
## 9. Add a 404 route
139139

tests/dummy/mirage/config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export default function (config) {
1414
path: '',
1515
name: '-latest',
1616
},
17-
master: {
17+
main: {
1818
sha: '12345',
1919
tag: null,
20-
path: 'master',
21-
name: 'master',
20+
path: 'main',
21+
name: 'main',
2222
},
2323
};
2424
});

0 commit comments

Comments
 (0)