Skip to content

Commit

Permalink
Merge pull request #730 from WildMeOrg/release-workflow
Browse files Browse the repository at this point in the history
Github CI Release Tagging
  • Loading branch information
bluemellophone committed Jun 27, 2022
2 parents 8dbe188 + 8f7618d commit 1a91a3e
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 148 deletions.
131 changes: 111 additions & 20 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,140 @@
name: Docker

on: push
on:
pull_request:
paths:
- '.github/workflows/nightly.yml'
- 'scripts/**'
push:
paths:
- '.github/workflows/nightly.yml'
- 'scripts/**'
branches:
- main
tags:
- v*
schedule:
- cron: '0 16 * * *' # Every day at 16:00 UTC (~09:00 PT)

jobs:
# Push container image to GitHub Packages and Docker Hub.
# See also https://docs.docker.com/docker-hub/builds/
deploy:
name: Docker image build
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2
if: github.event_name == 'schedule'
with:
submodules: true
ref: main

- uses: actions/checkout@v2
if: github.event_name != 'schedule'
with:
submodules: true

- uses: docker/setup-qemu-action@v1
name: Set up QEMU
id: qemu
with:
image: tonistiigi/binfmt:latest
platforms: all

- uses: docker/setup-buildx-action@v1
name: Set up Docker Buildx
id: buildx

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

# Build images
- name: Install package and build image
- name: Build Codex
run: |
./scripts/codex/build.sh
./scripts/codex/buildx.sh
# Log into container registries
- name: Log into Docker Hub
run: echo "${{ secrets.WBIA_WILDMEBOT_DOCKER_HUB_TOKEN }}" | docker login -u wildmebot --password-stdin
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: wildmebot
password: ${{ secrets.WBIA_WILDMEBOT_DOCKER_HUB_TOKEN }}

- name: Log into GitHub Packages
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}

# ############################################################
# Push Tagged image to registries
- name: Push to GitHub Packages
# Push tagged image (version tag + latest) to registries
- name: Tagged Docker Hub
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
run: |
VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##')
./scripts/utils/publish.sh -t ${VERSION} -r docker.pkg.github.com houston
- name: Push to Docker Hub
./scripts/utils/buildx.docker.sh -t ${VERSION}
./scripts/utils/buildx.docker.sh -t latest
- name: Tagged GHCR
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
run: |
VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##')
./scripts/utils/publish.sh -t ${VERSION} houston
./scripts/utils/buildx.docker.sh -t ${VERSION} -r ghcr.io/wildmeorg/houston
./scripts/utils/buildx.docker.sh -t latest -r ghcr.io/wildmeorg/houston
# ############################################################
# Push latest image to registries
- name: Push to GitHub Packages
# Push bleeding-edge image (main tag) to registries
- name: Bleeding Edge Docker Hub
if: github.ref == 'refs/heads/main'
run: |
./scripts/utils/publish.sh -t latest -r docker.pkg.github.com houston
- name: Push to Docker Hub
./scripts/utils/buildx.docker.sh -t main
- name: Bleeding Edge GHCR
if: github.ref == 'refs/heads/main'
run: |
./scripts/utils/publish.sh -t latest houston
./scripts/utils/buildx.docker.sh -t main -r ghcr.io/wildmeorg/houston
# Push nightly image (nightly tag) to registries
- name: Nightly Docker Hub
if: github.event_name == 'schedule'
run: |
./scripts/utils/buildx.docker.sh -t nightly
- name: Nightly GHCR
if: github.event_name == 'schedule'
run: |
./scripts/utils/buildx.docker.sh -t nightly -r ghcr.io/wildmeorg/houston
# Notify status in Slack
- name: Slack Notification
if: ${{ failure() && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
uses: rtCamp/action-slack-notify@master
env:
SLACK_CHANNEL: dev-houston
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://avatars.slack-edge.com/2020-03-02/965719891842_db87aa21ccb61076f236_44.png
SLACK_MESSAGE: 'Tagged / Latest Docker build of Houston failed :sob:'
SLACK_USERNAME: "GitHub CI"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Slack Notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: rtCamp/action-slack-notify@master
env:
SLACK_CHANNEL: dev-houston
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://avatars.slack-edge.com/2020-03-02/965719891842_db87aa21ccb61076f236_44.png
SLACK_MESSAGE: 'Bleeding Edge Docker build of Houston failed :sob:'
SLACK_USERNAME: "GitHub CI"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Slack Notification
if: ${{ failure() && github.event_name == 'schedule' }}
uses: rtCamp/action-slack-notify@master
env:
SLACK_CHANNEL: dev-houston
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://avatars.slack-edge.com/2020-03-02/965719891842_db87aa21ccb61076f236_44.png
SLACK_MESSAGE: 'Nightly Docker build of Houston failed :sob:'
SLACK_USERNAME: "GitHub CI"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
116 changes: 0 additions & 116 deletions .github/workflows/nightly.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -35,6 +36,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -59,6 +61,7 @@ jobs:
steps:
# Checkout and env setup
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -151,3 +154,27 @@ jobs:
run: |
docker-compose logs --tail=250
docker-compose ps
build_frontend:
name: Ensure frontend code builds
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Build the frontend
run: |
./scripts/codex/build.frontend.sh
build_swagger:
name: Ensure swagger UI code builds
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Build the swagger UI
run: |
./scripts/swagger/build.sh
12 changes: 12 additions & 0 deletions scripts/codex/build.preamble.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

./scripts/utils/clean.sh

# Install the package
./scripts/codex/install.sh

# Build and deploy frontend
./scripts/codex/build.frontend.sh

# Build and deploy Swagger UI
./scripts/swagger/build.sh
11 changes: 1 addition & 10 deletions scripts/codex/build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#!/bin/bash

./scripts/utils/clean.sh

# Install the package
./scripts/codex/install.sh

# Build and deploy frontend
./scripts/codex/build.frontend.sh

# Build and deploy Swagger UI
./scripts/swagger/build.sh
./scripts/codex/build.preamble.sh

# Build docker image
./scripts/codex/build.docker.sh
1 change: 1 addition & 0 deletions scripts/codex/buildx.docker.sh
6 changes: 6 additions & 0 deletions scripts/codex/buildx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

./scripts/codex/build.preamble.sh

# Build docker image
./scripts/codex/buildx.docker.sh
Loading

0 comments on commit 1a91a3e

Please sign in to comment.