Skip to content

Commit

Permalink
init release
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-1987 committed Jan 20, 2022
1 parent 3ba6a3a commit 8e8b9e9
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint

on:
pull_request:


jobs:
golangci:
name: 🔍 golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.43
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
skip-go-installation: false
28 changes: 28 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- errcheck
- gofmt
- gosec
- gosimple
- govet
- ineffassign
- misspell
- prealloc
- staticcheck
- structcheck
- typecheck
- unconvert
- unused
- varcheck

run:
# default concurrency is a available CPU number.
# concurrency: 2 # explicitly omit this value to fully utilize available resources.
timeout: 2m
modules-download-mode: readonly
deadline: 5m
issues-exit-code: 0
tests: false
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# gh-deploy
A `gh` cli extension to approve or reject pending deployments that are waiting for review.

## Installation

Installation requires a minimum version (2.0.0) of the the Github CLI to support extensions.

1. Install the `gh cli` - see the [installation/upgrade instructions](https://github.com/cli/cli#installation)

2. Install this extension:
```sh
gh extension install yuri-1987/gh-deploy
```

## Usage
```sh
gh deploy --help

Usage:
gh-deploy [OPTIONS]

Application Options:
-r, --repo= Github reposiory name including owner
-e, --env= Github environment name
-i, --run-id= Github Action run id to approve
--approve Approve deployment
--reject Reject deployment

Help Options:
-h, --help Show this help message
```
To **approve** pending deployment by run-id:
```sh
gh deploy --env prod --run-id 1723641358 --repo "yuri-1987/tf-iac" --approve
```
To **reject** pending deployment by run-id:
```sh
gh deploy --env prod --run-id 1723641358 --repo "yuri-1987/tf-iac" --reject
```

## Use cases
Set environment protection rules for your Github repository, ie. `prod` environment requires a review from your team members.

send them a slack message with the details of the deployment via github action.

**_workflow snippet:_**
```yaml
deployment_job_name:
runs-on: ubuntu-latest
steps:
- name: send slack message for approval
uses: act10ns/slack@v1.5.0
with:
status: "tf prod waiting for approval"
channel: '#deployments'
message: |
*Terraform Apply for Production env in `${{ github.repository }}` is pending approval*
Review requested by ${{ github.actor }}
Please review it here: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>
To *approve*, run:
```
gh deploy --env prod --run-id ${{ github.run_id }} --repo "${{ github.repository }}" --approve
```
To *reject*, run:
```
gh deploy --env prod --run-id ${{ github.run_id }} --repo "${{ github.repository }}" --reject
```
<{{diffUrl}}|Link to PR diff in branch: `{{branch}}`>
```
19 changes: 19 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e

tag="${1}"

if [ "${tag}" == "" ]; then
echo "tag argument required"
exit 1
fi

rm -rf dist
GOOS=darwin GOARCH=amd64 go build -o "dist/darwin-x86_64-${tag}"
GOOS=darwin GOARCH=arm64 go build -o "dist/darwin-arm64-${tag}"
GOOS=linux GOARCH=386 go build -o "dist/linux-i386-${tag}"
GOOS=linux GOARCH=amd64 go build -o "dist/linux-x86_64-${tag}"
GOOS=windows GOARCH=386 go build -o "dist/windows-i386-${tag}"
GOOS=windows GOARCH=amd64 go build -o "dist/windows-x86_64-${tag}"

gh release create "$tag" ./dist/* --title="${tag}" --notes "${tag}"

0 comments on commit 8e8b9e9

Please sign in to comment.