Skip to content

Commit

Permalink
Add github_actions boilerplate (#11)
Browse files Browse the repository at this point in the history
* Add github_actions boilerplate

* Fix numbering

* Parameterize actions further to support forks

* remove dockerhub push
  • Loading branch information
EngHabu authored Apr 27, 2020
1 parent 0536f3f commit a28a384
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
20 changes: 20 additions & 0 deletions boilerplate-repo/boilerplate/lyft/github_workflows/Readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Golang Github Actions
~~~~~~~~~~~~~~~~~

Provides a two github actions workflows.

**To Enable:**

Add ``lyft/github_workflows`` to your ``boilerplate/update.cfg`` file.

Add a github secret ``flytegithub_repo`` with a the name of your fork (e.g. ``my_company/flytepropeller``).

The actions will push to 2 repos:

1. ``docker.pkg.github.com/lyft/<repo>/operator``
2. ``docker.pkg.github.com/lyft/<repo>/operator-stages`` : this repo is used to cache build stages to speed up iterative builds after.

There are two workflows that get deployed:

1. A workflow that runs on Pull Requests to build and push images to github registy tagged with the commit sha.
2. A workflow that runs on master merges that bump the patch version of release tag, builds and pushes images to github registry tagged with the version, commit sha as well as "latest"
31 changes: 31 additions & 0 deletions boilerplate-repo/boilerplate/lyft/github_workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Master

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: '0'
- name: Bump version and push tag
id: bump-version
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
- name: Push Docker Image to Github Registry
uses: whoan/docker-build-with-cache-action@v5
with:
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
image_name: ${{ secrets.flytegithub_repo }}/operator
image_tag: latest,${{ github.sha }},${{ steps.bump-version.outputs.tag }}
push_git_tag: true
registry: docker.pkg.github.com
build_extra_args: "--compress=true"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Pull Request

on:
pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Push Docker Image to Github Registry
uses: whoan/docker-build-with-cache-action@v5
with:
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
image_name: ${{ secrets.flytegithub_repo }}/operator
image_tag: ${{ github.sha }}
push_git_tag: true
registry: docker.pkg.github.com
16 changes: 16 additions & 0 deletions boilerplate-repo/boilerplate/lyft/github_workflows/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

mkdir -p ${DIR}/../../../.github/workflows

echo " - generating github action workflows in root directory."
sed -e "s/{{REPOSITORY}}/${REPOSITORY}/g" ${DIR}/master.yml > ${DIR}/../../../.github/workflows/master.yml
sed -e "s/{{REPOSITORY}}/${REPOSITORY}/g" ${DIR}/pull_request.yml > ${DIR}/../../../.github/workflows/pull_request.yml

0 comments on commit a28a384

Please sign in to comment.