Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: setup ghcr.io/oasisprotocol/nexus docker repository #827

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/827.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feature: push images to ghcr.io/oasisprotocol/nexus docker repository
40 changes: 39 additions & 1 deletion .github/workflows/docker-nexus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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 +38,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 +53,39 @@ jobs:
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-
25 changes: 24 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,26 @@ jobs:
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: |
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 }}
Loading