Skip to content

Commit

Permalink
feature: setup ghcr.io/oasisprotocol/nexus
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Dec 16, 2024
1 parent 1c85d9f commit 597d5af
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
39 changes: 38 additions & 1 deletion .github/workflows/docker-nexus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
push:
branches:
- main
- ptrus/feature/docker-opf-nexus # TODO: remove
paths-ignore: # Do not trigger if _only_ these files were changed.
- .punch_version.py
- .changelog/*.md
Expand All @@ -24,6 +25,7 @@ jobs:
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

Expand All @@ -37,7 +39,8 @@ jobs:
# 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
- name: Build and push Docker to DockerHub
uses: docker/build-push-action@v3
with:
build-args: |
Expand All @@ -51,3 +54,37 @@ jobs:
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
- 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-
24 changes: 23 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
# For more info, see:
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Prepare the tagged Docker image.
- name: Set release tag
run: |
Expand All @@ -65,3 +65,25 @@ jobs:
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
# Prepare the tagged Docker image for 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: |
TAG=${{ env.TAG }}
context: .
file: docker/nexus/Dockerfile
tags: |
ghcr.io/oasisprotocol/nexus:${{ env.TAG }}
push: true
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}

0 comments on commit 597d5af

Please sign in to comment.