name: Build Docker image | |
on: | |
push: | |
tags: | |
- v* | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push: | |
name: Build and push Docker image to registry | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'nebulaservices' | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Setup docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login To registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}/nebulaservice/nebula | |
- name: Build and push | |
id: build-and-push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
file: ./Dockerfile | |
name: nebula | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |