build #45
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: build | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
permissions: | |
# Checkout repository | |
contents: read | |
# Push container images | |
packages: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image_variant: ['', 'sampledata', 'notls', 'fulldata'] | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
# - name: Docker meta | |
# id: meta | |
# if: ${{ github.event_name != 'pull_request' }} | |
# uses: docker/metadata-action@v5 | |
# with: | |
# images: | | |
# ghcr.io/${{ github.repository }} | |
# tags: | | |
# type=edge,enable=true,priority=700,prefix=,suffix=${{ matrix.image_variant }},branch=$repo.default_branch | |
# type=ref,event=pr | |
# type=semver,pattern={{version}} | |
# type=semver,pattern={{major}}.{{minor}} | |
# type=semver,pattern={{major}} | |
- name: Login to GitHub Container Registry | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Download data for full data variant | |
if: ${{ matrix.image_variant == 'fulldata' }} | |
run: | | |
rm glvd.sql | |
LATEST_RUN_ID=$(gh run list --repo gardenlinux/glvd-contrib --branch main --json workflowDatabaseId --limit 1 | jq -r '.[0].workflowDatabaseId') | |
gh run download $LATEST_RUN_ID -n glvd.sql --repo gardenlinux/glvd-contrib | |
ls -la | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Build and push image | |
if: ${{ github.event_name != 'pull_request' }} | |
run: | | |
docker buildx build --file=Containerfile --platform=linux/amd64,linux/arm64 --push --build-arg container_variant=${{ matrix.image_variant }} --tag=ghcr.io/gardenlinux/glvd-postgres:edge${{ matrix.image_variant }} . | |
- name: Build image in PR | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
docker buildx build --file=Containerfile --platform=linux/amd64,linux/arm64 --load --build-arg container_variant=${{ matrix.image_variant }} --tag=ghcr.io/gardenlinux/glvd-postgres:edge${{ matrix.image_variant }} . | |
# - name: Build and push image | |
# if: ${{ github.event_name != 'pull_request' }} | |
# uses: docker/build-push-action@v5 | |
# with: | |
# platforms: linux/amd64,linux/arm64 | |
# file: Containerfile | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# build-args: container_variant=${{ matrix.image_variant }} |