Skip to content

Commit

Permalink
github: Add docker workflow for testing building Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanez committed Jul 2, 2021
1 parent b830cf6 commit c826388
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .changelog/222.internal.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github: Add [docker workflow] for testing building Docker images

[docker workflow]:
https://github.com/oasisprotocol/oasis-core/actions?query=workflow:docker
74 changes: 74 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
name: docker

# NOTE: The purpose of this workflow is only to test if Docker images build
# successfully.
# Oasis recommends using binaries from the official GitHub releases as described
# in repo's docker/README.md.

# Trigger the workflow when:
on:
# A push occurs to one of the matched branches.
push:
# XXX: ideally on master branches we would build the image only if there are changes in the
# 'docker/' directory (as we do in pull_requests). However, this doesn't work when pushing a new
# 'stable/*' branch - the build on a new branch does not trigger unless there are changes
# compared to master on the filtered path.
# If this is ever fixed, or per branch filters are possible, bring back the path filter to only
# build the image when there are changes within 'docker/' directory.
branches:
- master
- stable/*
# Or when a pull request event occurs for a pull request against one of the matched branches and at least
# one modified file matches the configured paths.
#
# NOTE: We use this to be able to easily test Docker image changes.
pull_request:
branches:
- master
- stable/*
paths:
- docker/**
# Or every day at 04:00 UTC (for the default/master branch).
schedule:
- cron: "0 4 * * *"

jobs:

build-images:
# NOTE: This name appears in GitHub's Checks API.
name: build-images
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Determine tag name
id: determine_tag
shell: bash
run: |
if [[ -z $GITHUB_BASE_REF ]]; then
# On master/stable branches.
branch=${GITHUB_REF#refs/heads/}
else
# On pull request branches.
branch=pr-$(git describe --always --match '' --abbrev=7)
fi
branch=${branch//\//-}
echo "::set-output name=tag::${branch}"
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: "Rebuild oasisprotocol/oasis-core-rosetta-gateway:${{ steps.determine_tag.outputs.tag }}"
uses: docker/build-push-action@v2.5.0
with:
context: docker
file: docker/Dockerfile
tags: oasisprotocol/oasis-core-rosetta-gateway:${{ steps.determine_tag.outputs.tag }}
pull: true
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.determine_tag.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}

0 comments on commit c826388

Please sign in to comment.