Skip to content

Initial commit

Initial commit #1

Workflow file for this run

name: Build and Push Container Image
on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}/myapp
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDPLATFORM=${{ matrix.platform }}
TARGETPLATFORM=${{ matrix.platform }}
TARGETOS=${{ matrix.os }}
TARGETARCH=${{ matrix.arch }}
platforms: linux/amd64,linux/arm64
- name: Build and push Docker image for PR
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDPLATFORM=${{ matrix.platform }}
TARGETPLATFORM=${{ matrix.platform }}
TARGETOS=${{ matrix.os }}
TARGETARCH=${{ matrix.arch }}
platforms: linux/amd64,linux/arm64