Skip to content

Commit

Permalink
Replace CircleCI with GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jvasseur committed May 10, 2023
1 parent 091fa8f commit 3b60a63
Show file tree
Hide file tree
Showing 24 changed files with 530 additions and 1,415 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ insert_final_newline = true
[{package.json,yarn.lock}]
indent_size = 2

[generators/*/templates/circleci.yaml.ejs]
[generators/*/templates/workflow.yaml.ejs]
indent_size = 2

[generators/*/templates/ansible/**/*.yaml.ejs]
Expand Down
7 changes: 0 additions & 7 deletions generators/express/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from 'path';
import execa from 'execa';
import YAML from 'yaml';
import helpers from 'yeoman-test';
import { Config } from '../../utils/circleci';

describe('When running the generator', () => {
let root: string;
Expand Down Expand Up @@ -90,12 +89,6 @@ describe('When running the generator with kubernetes deployment', () => {
await fs.promises.rm(root, { recursive: true });
});

test('It generates a valid CircleCI config', async () => {
const content = await fs.promises.readFile(path.join(root, '.circleci', 'config.yml'), 'utf8');

Config.fromRaw(YAML.parse(content));
});

test('It generates a valid terraform config', async () => {
const cwd = path.join(root, 'environments', 'staging');

Expand Down
8 changes: 4 additions & 4 deletions generators/express/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ExpressGenerator extends PackageGenerator {

this.configureDockerCompose('docker-compose.yaml.ejs');

this.configureCircleCI('circleci.yaml.ejs');
this.renderTemplate('workflow.yaml.ejs', `.github/workflows/${packageName}.yaml`);

switch (this.config.get('deployment')) {
case DeploymentChoice.Ansible:
Expand All @@ -33,9 +33,9 @@ class ExpressGenerator extends PackageGenerator {
cookieSecret: cryptoRandomString({ length: 64, type: 'alphanumeric' }),
});

this.updateCircleCIConfig((config) => {
config.workflows.build!.jobs.deploy!.requires.push(`${packageName}-archive`);
});
// this.updateCircleCIConfig((config) => {
// config.workflows.build!.jobs.deploy!.requires.push(`${packageName}-archive`);
// });
break;
case DeploymentChoice.Kubernetes: {
const packageVar = varName(packageName);
Expand Down
186 changes: 0 additions & 186 deletions generators/express/templates/circleci.yaml.ejs

This file was deleted.

99 changes: 99 additions & 0 deletions generators/express/templates/workflow.yaml.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: <%= packageName %>

on:
pull_request:
paths: <%= packagePath %>/**
push:
branches:
- main
- develop

defaults:
run:
working-directory: <%= packagePath %>

jobs:
code-style:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint

test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn test

<% if (deployment === 'ansible') { %>
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: yarn
- run: yarn install --frozen-lockfile
- run: echo "export default '${{ github.sha }}';" > src/version.ts
- run: yarn build
env:
NODE_ENV: production
- run: yarn install --frozen-lockfile --prod
- run: |
tar --create \
--gzip \
--file=archive.tar.gz \
--owner=0 \
--group=0 \
--exclude '*.map' \
dist/ \
node_modules/ \
- uses: actions/upload-artifact@v3
with:
name: <%= packageName %>
path: archive.tar
if-no-files-found: error
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
- uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: <%= projectName %>-<%= packageName %>
with:
sourcemaps: dist
version_prefix: <%= projectName %>-<%= packageName %>@
working_directory: <%= packagePath %>
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
<% } %>
<% if (deployment === 'kubernetes') { %>
build:
runs-on: ubuntu-22.04
steps:
- uses: docker/setup-buildx-action@v2.5.0
- uses: docker/login-action@v2.1.0
with:
registry: ${{ secrets.STAGING_REGISTRY }}
username: ${{ secrets.STAGING_REGISTRY_LOGIN }}
password: ${{ secrets.STAGING_REGISTRY_PASSWORD }}
if: github.ref == 'refs/heads/develop'
- uses: docker/build-push-action@v4.0.0
with:
context: '{{ defaultContext }}:<%= packagePath %>'
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ secrets.STAGING_REGISTRY }}/<%= projectName %>/<%= packageName %>:latest
push: ${{ github.ref == 'refs/heads/develop' }}
build-args: |
VERSION=${{ github.sha }}
<% } %>
7 changes: 0 additions & 7 deletions generators/next-js/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from 'path';
import execa from 'execa';
import YAML from 'yaml';
import helpers from 'yeoman-test';
import { Config } from '../../utils/circleci';

describe('When running the generator', () => {
let root: string;
Expand Down Expand Up @@ -64,12 +63,6 @@ describe('When running the generator with kubernetes deployment', () => {
await fs.promises.rm(root, { recursive: true });
});

test('It generates a valid CircleCI config', async () => {
const content = await fs.promises.readFile(path.join(root, '.circleci', 'config.yml'), 'utf8');

Config.fromRaw(YAML.parse(content));
});

test('It generates a valid terraform config', async () => {
const cwd = path.join(root, 'environments', 'staging');

Expand Down
8 changes: 4 additions & 4 deletions generators/next-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ class NextJSGenerator extends PackageGenerator {

this.configureDockerCompose('docker-compose.yaml.ejs');

this.configureCircleCI('circleci.yaml.ejs');
this.renderTemplate('workflow.yaml.ejs', `.github/workflows/${packageName}.yaml`);

switch (this.config.get('deployment')) {
case DeploymentChoice.Ansible:
this.configureAnsible('deployment/ansible', {
repositoryName: this.config.get('repositoryName'),
});

this.updateCircleCIConfig((config) => {
config.workflows.build!.jobs.deploy!.requires.push(`${packageName}-archive`);
});
// this.updateCircleCIConfig((config) => {
// config.workflows.build!.jobs.deploy!.requires.push(`${packageName}-archive`);
// });
break;
case DeploymentChoice.Kubernetes: {
const packageVar = varName(packageName);
Expand Down
Loading

0 comments on commit 3b60a63

Please sign in to comment.