Docker #2159
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 | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- master | |
- release/v* | |
- release/miner/v* | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Publish the Docker image' | |
required: false | |
default: 'false' | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
jobs: | |
docker: | |
name: Docker (${{ matrix.image }} / ${{ matrix.network }}) [publish=${{ github.event.inputs.publish == 'true' || github.event_name != 'pull_request' }}] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
image: | |
- lotus-all-in-one | |
network: | |
- mainnet | |
- butterflynet | |
- calibnet | |
- debug | |
include: | |
- image: lotus | |
network: mainnet | |
env: | |
PUBLISH: ${{ github.event.inputs.publish == 'true' || github.event_name != 'pull_request' }} | |
steps: | |
- id: channel | |
env: | |
IS_MASTER: ${{ github.ref == 'refs/heads/master' }} | |
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }} | |
IS_RC: ${{ contains(github.ref, '-rc') }} | |
IS_SCHEDULED: ${{ github.event_name == 'schedule' }} | |
run: | | |
channel='' | |
if [[ "$IS_MASTER" == 'true' ]]; then | |
if [[ "$IS_SCHEDULED" == 'true' ]]; then | |
channel=nightly | |
else | |
channel=master | |
fi | |
elif [[ "$IS_TAG" == 'true' ]]; then | |
if [[ "$IS_RC" == 'true' ]]; then | |
channel=candidate | |
else | |
channel=stable | |
fi | |
fi | |
echo "channel=$channel" | tee -a $GITHUB_OUTPUT | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
fetch-depth: 0 | |
- id: git | |
run: | | |
ref="${GITHUB_REF#refs/heads/}" | |
ref="${ref#refs/tags/}" | |
sha="$(git rev-parse --short HEAD)" | |
echo "ref=$ref" | tee -a "$GITHUB_OUTPUT" | |
echo "sha=$sha" | tee -a "$GITHUB_OUTPUT" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: filecoin/${{ matrix.image }} | |
tags: | | |
type=raw,enable=${{ steps.channel.outputs.channel != '' }},value=${{ steps.channel.outputs.channel }} | |
type=raw,enable=${{ startsWith(github.ref, 'refs/tags/') }},value=${{ steps.git.outputs.ref }} | |
type=raw,value=${{ steps.git.outputs.sha }} | |
flavor: | | |
latest=false | |
suffix=${{ matrix.network != 'mainnet' && format('-{0}', matrix.network) || '' }} | |
- if: env.PUBLISH == 'true' | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push if channel is set (channel=${{ steps.channel.outputs.channel }}) | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: ${{ env.PUBLISH == 'true' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
${{ matrix.network != 'mainnet' && format('GOFLAGS=-tags={0}', matrix.network) || ''}} |