Publish images #961
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: Publish images | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */6 * * *' # every 6 hours | |
jobs: | |
push_lodestar-validator: | |
name: Publish Lodestar Validator image | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
id-token: write | |
attestations: write | |
contents: write | |
pull-requests: write | |
steps: | |
# checks latest release from external repo | |
- id: base | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
repository: ChainSafe/lodestar | |
excludes: prerelease, draft | |
- uses: action-pack/tag-exists@v1 | |
id: check | |
with: | |
tag: ${{ steps.base.outputs.release }} | |
- name: Exit if tag exists | |
if: ${{ steps.check.outputs.exists == 'true' }} | |
run: | | |
echo "Update dockerfile to ${{ steps.base.outputs.release }} already exists" | |
exit 1 | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
# Create a new dockerfile from template with new version | |
- id: sub | |
uses: bluwy/substitute-string-action@v3 | |
with: | |
_input-file: Dockerfile.template | |
_output-file: Dockerfile | |
LODESTAR_VERSION: ${{ steps.base.outputs.release }} | |
- name: Commit dockerfile | |
if: ${{ steps.check.outputs.exists == 'false' }} | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add Dockerfile | |
git commit -m "Update dockerfile to ${{ steps.base.outputs.release }}" | |
- name: Push changes to main | |
if: ${{ steps.check.outputs.exists == 'false' }} | |
uses: ad-m/github-push-action@master | |
with: | |
branch: "main" | |
force: true | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }}/lodestar-validator | |
tags: | | |
type=raw,value=${{ steps.base.outputs.release }} | |
- name: Build and push Lodestar Validator | |
id: push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
file: Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: attest | |
uses: actions/attest-build-provenance@v1 | |
id: attest | |
with: | |
subject-name: ghcr.io/${{ github.repository }}/lodestar-validator | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true | |
- name: Create Release | |
id: create-release | |
uses: action-pack/github-release@v2 | |
if: ${{ steps.check.outputs.exists == 'false' }} | |
with: | |
tag: ${{ steps.base.outputs.release }} | |
title: Upstream-${{ steps.base.outputs.release }} | |
body: ${{ steps.base.outputs.description }} |