Add Github CI #8
Workflow file for this run
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: CI | ||
env: | ||
FOUNDRY_PROFILE: ci | ||
DOCKER_BUILDKIT: 1 | ||
REGISTRY: ghcr.io | ||
REPO: ${{ github.repository_owner }} | ||
on: | ||
push: | ||
branches: [celestia-develop] | ||
pull_request: | ||
branches: [celestia-develop] | ||
workflow_dispatch: | ||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
strategy: | ||
matrix: | ||
component: | ||
- op-node | ||
- op-batcher | ||
- op-program | ||
- op-proposer | ||
- op-challenger | ||
- proofs-tools | ||
- op-dispute-mon | ||
- op-conductor | ||
- da-server | ||
- op-supervisor | ||
- cannon | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Prepare Docker Tags | ||
id: prep | ||
shell: bash | ||
run: | | ||
# Get short SHA | ||
SHA="$(git rev-parse --short HEAD)" | ||
# Sanitize branch name using parameter expansion | ||
BRANCH="${GITHUB_REF#refs/heads/}" | ||
BRANCH="${BRANCH//[^a-zA-Z0-9._-]/-}" | ||
# For pull requests, use PR number | ||
if [[ "${GITHUB_REF}" == refs/pull/* ]]; then | ||
PR_NUMBER="$(echo "${GITHUB_REF}" | cut -d / -f 3)" | ||
TAGS="${REGISTRY}/${REPO}/${{ matrix.component }}:pr-${PR_NUMBER}" | ||
else | ||
TAGS="${REGISTRY}/${REPO}/${{ matrix.component }}:${SHA}" | ||
# Add branch tag if not a PR | ||
if [ -n "${BRANCH}" ]; then | ||
TAGS="${TAGS},${REGISTRY}/${REPO}/${{ matrix.component }}:${BRANCH}" | ||
fi | ||
fi | ||
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.prep.outputs.tags }} | ||
platforms: linux/amd64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
- name: Save Docker image for testing | ||
if: github.event_name == 'pull_request' | ||
shell: bash | ||
run: | | ||
FIRST_TAG="$(echo "${{ steps.prep.outputs.tags }}" | cut -d',' -f1)" | ||
docker save "${FIRST_TAG}" > "/tmp/${{ matrix.component }}.tar" | ||
- name: Upload Docker image | ||
if: github.event_name == 'pull_request' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: docker-${{ matrix.component }} | ||
path: /tmp/${{ matrix.component celestia- | ||
Check failure on line 96 in .github/workflows/ci.yml GitHub Actions / CIInvalid workflow file
|