blob: 2cf02c8d9d0a5019172aaab1fb4abaf231459520 [file] [log] [blame]
# Copyright 2021 SkyWater PDK Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache 2.0
name: Build Docker Image for Run DRC for cell GDS (using Magic) Action
on:
workflow_dispatch:
push:
pull_request_target:
permissions:
contents: read
jobs:
# FIXME: Remove once GitHub Container Registry is working.
# docker.pkg.github.com doesn't support buildx built packages, use
# docker/build-push-action instead.
build-github-package:
name: "Building Docker GitHub Package."
runs-on: ubuntu-latest
permissions:
packages: write # ${{ github.event_name == "push" || github.event_name == "workflow_dispatch" }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
# Always clone the full depth so git-describe works.
fetch-depth: 0
submodules: true
- name: Set Action Name
run: echo "ACTION_NAME=run-drc-for-cell-gds-using-magic" >> $GITHUB_ENV
- name: Build container image
uses: docker/build-push-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.repository_owner }}
password: ${{ github.token }}
repository: ${{ github.repository }}/${{ env.ACTION_NAME }}
path: ${{ env.ACTION_NAME }}
tag_with_ref: true
tag_with_sha: true
add_git_labels: true
push: ${{ startsWith(github.ref, 'refs/heads/') }}
build-docker-image:
name: "Building image."
runs-on: ubuntu-latest
# Run a local registry
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Dump context
uses: crazy-max/ghaction-dump-context@v1
- name: Checkout code
uses: actions/checkout@v2
with:
# Always clone the full depth so git-describe works.
fetch-depth: 0
submodules: true
- name: Set Action Name
run: echo "ACTION_NAME=run-drc-for-cell-gds-using-magic" >> $GITHUB_ENV
- name: Detect Push To Config
id: push_to
shell: python
env:
HAS_GCR_JSON_KEY: ${{ !!(secrets.GCR_JSON_KEY) }}
run: |
import os
gh_event = os.environ['GITHUB_EVENT_NAME']
i = []
print("Adding local service.")
i.append("localhost:5000/${{ env.ACTION_NAME }}")
if "${{ env.HAS_GCR_JSON_KEY }}":
print("Adding Google Container Repository (gcr.io)")
i.append("gcr.io/skywater-pdk/actions/${{ env.ACTION_NAME }}")
#print("Adding GitHub Container Repository (ghcr.io)")
#i.append("ghcr.io/${{ github.repository }}/${{ env.ACTION_NAME }}")
l = ",".join(i)
print("Final locations:", repr(l))
print("::set-output name=images::{}".format(l))
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
with:
images: ${{ steps.push_to.outputs.images }}
tags: |
type=ref,event=tag
type=ref,event=pr
type=ref,event=branch
type=sha
type=sha,format=long
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Login to Google Container Registry
if: ${{ contains(steps.push_to.outputs.images, 'gcr.io') }}
uses: docker/login-action@v1
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}
- name: Login to GitHub Container Registry
if: ${{ contains(steps.push_to.outputs.images, 'ghcr.io') }}
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ github.token }}
registry: ghcr.io
- name: Build and push
uses: docker/build-push-action@v2
id: docker_build
with:
context: ${{ env.ACTION_NAME }}
file: ${{ env.ACTION_NAME }}/Dockerfile
push: true
tags: |
${{ steps.docker_meta.outputs.tags }}
localhost:5000/${{ env.ACTION_NAME }}:latest
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Inspect
run: docker buildx imagetools inspect localhost:5000/${{ env.ACTION_NAME }}:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}