Skip to content

Commit

Permalink
update dockerfile and ci scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
phlummox committed Jan 13, 2022
1 parent 81758c2 commit 88ab39a
Show file tree
Hide file tree
Showing 11 changed files with 467 additions and 150 deletions.
165 changes: 165 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@

name: build-push

on:
push:
paths-ignore:
- '**.md'
- '.gitignore'
- '.dockerignore'
pull_request:
paths-ignore:
- '**.md'
- '.gitignore'
- '.dockerignore'
release:
types:
- created

env:
REGISTRY: ghcr.io
DOCKER_HUB_OWNER: phlummox

jobs:
docker_build:
name: docker build
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
name: Check out code

- name: set docker image info
id: info
shell: bash
run: |
set -x
IMAGE_NAME=$(make print-image-name)
IMAGE_VERSION=$(make print-image-version)
echo "::set-output name=IMAGE_NAME::${IMAGE_NAME}"
echo "::set-output name=IMAGE_VERSION::${IMAGE_VERSION}"
- name: check info ok
run: |
IMAGE_NAME="${{ steps.info.outputs.IMAGE_NAME }}"
printf 'IMAGE_NAME is: <<%s>>\n' "${IMAGE_NAME}"
if [ -z ${IMAGE_NAME} ]; then
false
fi
IMAGE_VERSION="${{ steps.info.outputs.IMAGE_VERSION }}"
printf 'IMAGE_VERSION is: <<%s>>\n' "${IMAGE_VERSION}"
if [ -z ${IMAGE_VERSION} ]; then
false
fi
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Log in to github Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# not sure this is actually needed
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: print stuff
shell: bash
run: |
printf 'tags are: <<%s>>\n' "${{ steps.meta.outputs.tags }}"
printf 'tags labels are: <<%s>>\n' "${{ steps.meta.outputs.labels }}"
printf 'repos is: <<%s>>\n' "${{ github.repository }}"
# really, this is just using info that _mostly_
# could've been got from makefile.
# But some is from CI environment.
- name: Build Docker image
shell: bash
run: |
set -x
export IMAGE_NAME="${{ steps.info.outputs.IMAGE_NAME }}"
export GH_IMAGE_ID="${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.info.outputs.IMAGE_NAME }}"
export IMAGE_VERSION="${{ steps.info.outputs.IMAGE_VERSION }}"
export REPO_OWNER="${{ github.repository_owner }}"
echo "${{ steps.meta.outputs.labels }}" > oc_labels
# "
python3 ./build.py
- name: push to github registry
if: github.event_name != 'pull_request'
shell: bash
run: |
set -x
set -euo pipefail
GH_IMAGE_ID=${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.info.outputs.IMAGE_NAME }}
IMAGE_VERSION=${{ steps.info.outputs.IMAGE_VERSION }}
#docker push ${GH_IMAGE_ID}:${IMAGE_VERSION}-builder
docker push ${GH_IMAGE_ID}:${IMAGE_VERSION}
docker tag ${GH_IMAGE_ID}:${IMAGE_VERSION} ${GH_IMAGE_ID}:latest
docker push ${GH_IMAGE_ID}:latest
# whenever the tag looks like a version, we push
# to Docker Hub. It's up to the maintainer to ensure that
# the right version is being pushed (i.e. that what version
# the makefile spits out is the version for the current tag)
- name: push to docker registry
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
set -x
set -euo pipefail
GH_IMAGE_ID="${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.info.outputs.IMAGE_NAME }}"
DOCKER_IMAGE_ID="docker.io/${{ env.DOCKER_HUB_OWNER }}/${{ steps.info.outputs.IMAGE_NAME }}"
IMAGE_VERSION=${{ steps.info.outputs.IMAGE_VERSION }}
docker tag ${GH_IMAGE_ID}:${IMAGE_VERSION} ${DOCKER_IMAGE_ID}:${IMAGE_VERSION}
docker push ${DOCKER_IMAGE_ID}:${IMAGE_VERSION}
docker tag ${GH_IMAGE_ID}:latest ${DOCKER_IMAGE_ID}:latest
docker push ${DOCKER_IMAGE_ID}:latest
# "
- name: create release
if: startsWith(github.ref, 'refs/tags/v')
run: |
set -x
ref_name='${{github.ref_name}}'
version="${ref_name:1}" # strip leading 'v'
# download github-release tool
github_rel_url="https://github.com/github-release/github-release/releases/download/v0.10.0/linux-amd64-github-release.bz2"
curl -L "${github_rel_url}" | bunzip2 > github-release
chmod a+rx ./github-release
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
IFS='/' read repo_user repo_name <<<$(echo "${{github.repository}}")
./github-release release \
--user $repo_user \
--repo $repo_name \
--tag ${{github.ref_name}} \
--name "Version $version" \
--description "See the changelog for a detailed list of changes" \
--draft
27 changes: 0 additions & 27 deletions .gitpod.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .travis/docker_build

This file was deleted.

22 changes: 0 additions & 22 deletions .travis/docker_push

This file was deleted.

Loading

0 comments on commit 88ab39a

Please sign in to comment.