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

Send commits on build #367

Merged
merged 11 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/build-and-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Build and push docker image

on: [push]
on:
push:
branches:
- prod
- stage

env:
DOCKER_REPO: ${{ secrets.DOCKER_USERNAME }}/hawk-api
HAWK_TOKEN: ${{ secrets.HAWK_TOKEN }}

jobs:
build:
Expand All @@ -12,6 +17,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

# Get package new version name
- name: Get package info
id: packageInfo
uses: codex-team/action-nodejs-package-info@v1

- name: Send commits to Hawk
run: |
curl https://raw.githubusercontent.com/codex-team/hawk.release/feature/commits-sending-script/scripts/commits.sh -O
chmod +x ./commits.sh
./commits.sh -r=${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }} -t=${{ env.HAWK_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v1
with:
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Bump version in PR

on: [pull_request]

jobs:
# If pull request was merged then we should check for a package version update
check-version-update:
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2
with:
fetch-depth: 0

# Get package new version name
- name: Get package info
id: packageNew
uses: codex-team/action-nodejs-package-info@v1

# Checkout to the base commit before merge
- name: Checkout to the base commit before merge
run: git checkout ${{ github.event.pull_request.base.sha }}

# Get package old version name
- name: Get package info
id: packageOld
uses: codex-team/action-nodejs-package-info@v1

# Stop workflow and do not bump version if it was changed already
- name: Stop workflow and do not bump version if it was changed already
uses: andymckay/cancel-action@0.2
if: steps.packageOld.outputs.version != steps.packageNew.outputs.version

bump-version:
needs: check-version-update
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2

# Setup node environment
- uses: actions/setup-node@v1
with:
node-version: 15
registry-url: https://registry.npmjs.org/

# Bump version to the next prerelease (patch) with rc suffix
- name: Suggest the new version
run: yarn version --patch --no-git-tag-version

# Get package new version name
- name: Get package info
id: package
uses: codex-team/action-nodejs-package-info@v1

# Commit version upgrade
- uses: EndBug/add-and-commit@v7
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
message: "Bump version up to ${{ steps.package.outputs.version }}"
6 changes: 5 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import './src/env';
import HawkAPI from './src';
import HawkCatcher from '@hawk.so/nodejs';
import { name, version } from './package.json';

/** Enable HawkCatcher */
if (process.env.HAWK_CATCHER_TOKEN) {
HawkCatcher.init(process.env.HAWK_CATCHER_TOKEN);
HawkCatcher.init({
token: process.env.HAWK_CATCHER_TOKEN,
release: `${name}-${version}`,
});
}

const app = new HawkAPI();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawk.api",
"version": "1.0.0",
"version": "1.0.1",
"main": "index.ts",
"license": "UNLICENSED",
"scripts": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"typescript": "^3.7.5"
},
"dependencies": {
"@hawk.so/nodejs": "^3.0.10",
"@hawk.so/nodejs": "^3.1.1",
"@types/amqp-connection-manager": "^2.0.4",
"@types/debug": "^4.1.5",
"@types/escape-html": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"resolveJsonModule": true, /* Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@
dependencies:
"@f/map-obj" "^1.2.2"

"@hawk.so/nodejs@^3.0.10":
version "3.0.10"
resolved "https://registry.yarnpkg.com/@hawk.so/nodejs/-/nodejs-3.0.10.tgz#11e34f2572f53088913b1d45e3abfaa391386904"
integrity sha512-KpVk34n6ttX21KEJlGmKi7Pg4bh+x3x1Ot8O1Xy4ZRb+ob208PU/ThDEOeJgf/QH3QBTTNnNWK/HvjSW81TkHg==
"@hawk.so/nodejs@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@hawk.so/nodejs/-/nodejs-3.1.1.tgz#fc68b77833ce14f2491c77c58c724e51366c47dd"
integrity sha512-VzVGYDat+dEmtSFp777Ql9GYqHwliO5aoNbqdK3xAa7tbe3FPrSv4B8SsyJEJJuXkTjAKOlWmX0zjkjlY80A6w==
dependencies:
"@hawk.so/types" "^0.1.15"
axios "^0.21.1"
Expand Down