Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CD (continuous deployment) #58

Merged
merged 6 commits into from Aug 31, 2020
Merged

Conversation

ijlee2
Copy link
Member

@ijlee2 ijlee2 commented Aug 29, 2020

Description

I updated the GitHub Actions workflow so that it can deploy the app when a PR is merged.

This PR can close the issue #46.

Notes

There are 2 ways to set credentials for deployment:

1. Install ember-cli-deploy-git-ci

We must create public and private SSH keys. Then, we store the public key in Settings - Deploy keys and the private in Settings - Secrets so that it can be passed to the workflow as an environment variable.

Finally, we need to update the deploy configuration and workflow files:

// config/deploy.js

module.exports = function(deployTarget) {
  let ENV = {
    build: {},

    // include other plugin configuration that applies to all deploy targets here
    git: {
      repo: 'git@github.com:ember-learn/ember-octane-vs-classic-cheat-sheet.git',
    },

    'git-ci': {
      enabled: true,
      deployKey: process.env.SECRET_KEY,
    },
  };
};
# .github/workflows/ci-cd.yml

jobs:
  deploy-app:
    steps:
      - name: Deploy
        run: yarn deploy
        env:
          DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

2. Reuse auth token

Thanks to a Discord chat between Dan F. and Jan B., I found a simpler way to deploy from GitHub Actions.

This time, we set GitHub Actions as the user who want to deploy the app, but pass our auth token instead. The deploy configuration and workflow files need to be:

// config/deploy.js

module.exports = function(deployTarget) {
  let ENV = {
    build: {},

    // include other plugin configuration that applies to all deploy targets here
    git: {
      repo: 'https://github.com/ember-learn/ember-octane-vs-classic-cheat-sheet.git',
    },
  };
};
# .github/workflows/ci-cd.yml

jobs:
  deploy-app:
    steps:
      - name: Deploy
        run: yarn deploy

Notice the use of https in ENV.git.repo.

@@ -1,7 +1,7 @@
'use strict';

module.exports = {
test_page: 'tests/index.html?hidepassed',
test_page: 'tests/index.html?hidepassed&nolint',
Copy link
Member Author

@ijlee2 ijlee2 Aug 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added nolint query parameter so that ember-qunit skips lint checks by ember-cli-dependency-lint.

@ijlee2 ijlee2 force-pushed the add-continuous-deployment branch from 15e1ff2 to e113bb7 Compare Aug 29, 2020
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 5
Copy link
Member Author

@ijlee2 ijlee2 Aug 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a script to analyze past workflow runs in order to recommend a good value for timeout-minutes.

(In general, if a workflow is to fail, we want it to fail fast so that it doesn't cost us extra money. Currently, this is a concern only for private repos.)

I ran the script to find that 3 is a good value. Just in case, I set it to 5.

@ijlee2 ijlee2 linked an issue Aug 29, 2020 that may be closed by this pull request
@ijlee2 ijlee2 marked this pull request as ready for review Aug 29, 2020
@ijlee2 ijlee2 requested a review from a team Aug 29, 2020
@ijlee2 ijlee2 merged commit 28e3627 into master Aug 31, 2020
9 checks passed
@ijlee2 ijlee2 deleted the add-continuous-deployment branch Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run deployments with GitHub Actions
2 participants