name: Docker
on:
push:
branches: ["main"]
tags: ["v*"]
pull_request:
branches: ["main"]
permissions:
contents: read
packages: write
jobs:
build:
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref_type == 'branch')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: false
tags: casper-devnet:ci
release:
if: github.event_name == 'push' && github.ref_type == 'tag'
strategy:
matrix:
os: [ubuntu-latest, ubuntu-22.04-arm]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}