Merge pull request #838 from oasisprotocol/ptrus/feature/evm-abi-idx #276
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: docker-nexus # This name appears in GitHub's Checks API and in workflow's status badge. | |
# THIS WORKFLOW: | |
# Builds and pushes a Docker image at the current commit. | |
# This image is only offered for manual testing/debugging of a given PR/commit. | |
# It is not a dependency of any automated process. | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: # Do not trigger if _only_ these files were changed. | |
- .punch_version.py | |
- .changelog/*.md | |
- CHANGELOG.md | |
workflow_dispatch: # manual; for debugging workflow before merging branch into `main` | |
jobs: | |
build-docker: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
# We need history to determine oasis-indexer version from git tag. | |
fetch-depth: '0' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- name: Compute version | |
# Version oasis-indexer image by date and git revision. | |
run: | | |
echo "VERSION=$(date +%Y-%m-%d-git$(git rev-parse --short HEAD))" >> $GITHUB_ENV | |
- name: Build and push Docker to DockerHub | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: | | |
VERSION=${{ env.VERSION }} | |
context: . | |
file: docker/nexus/Dockerfile | |
tags: | | |
oasislabs/oasis-indexer:latest | |
oasislabs/oasis-indexer:latest-${{ env.VERSION }} | |
push: true | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
# Also push the image to ghcr.io/oasisprotocol/nexus. | |
# XXX: In future, we will remove the Dockerhub repository and only push to ghcr.io. | |
- name: Login to ghcr.io | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker to ghcr.io | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: | | |
VERSION=${{ env.VERSION }} | |
context: . | |
file: docker/nexus/Dockerfile | |
tags: | | |
ghcr.io/oasisprotocol/nexus:latest | |
ghcr.io/oasisprotocol/nexus:latest-${{ env.VERSION }} | |
push: true | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
- name: Prune old ghcr.io/oasisprotocol/nexus images | |
if: ${{ github.event_name == 'push' }} | |
uses: vlaurin/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
organization: oasisprotocol | |
container: nexus | |
keep-younger-than: 14 # days | |
keep-last: 4 | |
prune-untagged: true | |
prune-tags-regexes: ^latest- |