lotus/.github/workflows/docker.yml
Piotr Galar cfbe59d182
fix: ci: keep lotus checkout clean in the release workflow (#12028)
* ci: keep lotus checkout clean in the release workflow

* ci: allow providing custom ref to the release workflow

* ci: fix version check performed during the release

* ci: fix install go step of the release workflow

* ci: fix the working directory for the install go step in release workflow

* ci: provide github ref to lotus scripts explicitly

* ci: use actions from the chosen ref in release workflow

* ci: fix install go in release workflow

* ci: fix artifact upload in release workflow

* ci: set INPUTS_REF variable in release workflow

* ci: fix publish checksums script

* ci: allow releasing docker from an arbitrary ref

* ci: fix docker channel discovery
2024-05-22 14:47:29 +02:00

100 lines
3.1 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: {}
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 }}
- 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=schedule
type=raw,enable=${{ github.event_name != 'schedule' && steps.channel.outputs.channel != '' }},value=${{ steps.channel.outputs.channel }}
type=ref,event=tag
type=sha,prefix=
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) || ''}}