109 lines
3.4 KiB
YAML
109 lines
3.4 KiB
YAML
name: Docker
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- release/*
|
|
tags:
|
|
- v*
|
|
schedule:
|
|
- cron: '0 0 * * *'
|
|
workflow_dispatch:
|
|
inputs:
|
|
ref:
|
|
description: The GitHub ref (e.g. refs/tags/v1.0.0) to release
|
|
required: false
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
docker:
|
|
name: Docker (${{ matrix.image }} / ${{ matrix.network }}) [publish=${{ (inputs.ref || github.ref) == 'refs/heads/master' || startsWith(inputs.ref || github.ref, 'refs/tags/') }}]
|
|
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.ref == 'refs/heads/master' || startsWith(inputs.ref || github.ref, 'refs/tags/') }}
|
|
steps:
|
|
- id: channel
|
|
env:
|
|
IS_MASTER: ${{ (inputs.ref || github.ref) == 'refs/heads/master' }}
|
|
IS_TAG: ${{ startsWith(inputs.ref || github.ref, 'refs/tags/') }}
|
|
IS_RC: ${{ contains(inputs.ref || 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'
|
|
ref: ${{ inputs.ref || github.ref }}
|
|
- id: git
|
|
env:
|
|
REF: ${{ inputs.ref || github.ref }}
|
|
run: |
|
|
ref="${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(inputs.ref || 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) || ''}}
|