Skip to content

Merge pull request #63 from GoogleCloudPlatform/dependabot/go_modules… #148

Merge pull request #63 from GoogleCloudPlatform/dependabot/go_modules…

Merge pull request #63 from GoogleCloudPlatform/dependabot/go_modules… #148

Workflow file for this run

# Copyright 2022 Google LLC
#
# 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
#
# http://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.
name: "Build and push container image"
on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: pubsub2inbox
JSON_IMAGE_NAME: json2pubsub
jobs:
build-push-container-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install cosign
run: |
wget -q "https://github.com/sigstore/cosign/releases/download/v1.13.1/cosign-linux-amd64"
mv cosign-linux-amd64 /usr/local/bin/cosign
chmod +x /usr/local/bin/cosign
- name: Get version number
run: |
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
else
echo "VERSION=latest" >> $GITHUB_ENV
fi
echo "IMAGE_TAG=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]' >> $GITHUB_ENV
echo "JSON_IMAGE_TAG=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.JSON_IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]' >> $GITHUB_ENV
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build
uses: docker/build-push-action@v3
with:
push: true
tags: |
${{ env.image_tag }}:${{ env.VERSION }}
labels: |
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.title=Pubsub2Inbox
org.opencontainers.image.vendor=Google LLC
org.opencontainers.image.version=${{ env.VERSION }}
- name: Build and push Json2Pubsub
id: build-json2pubsub
uses: docker/build-push-action@v3
with:
context: cmd/json2pubsub
push: true
tags: |
${{ env.json_image_tag }}:${{ env.VERSION }}
labels: |
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.title=Json2Pubsub
org.opencontainers.image.vendor=Google LLC
org.opencontainers.image.version=${{ env.VERSION }}
- name: Sign image
env:
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
run: |
/usr/local/bin/cosign sign --key env://COSIGN_KEY ${{ env.image_tag }}@${{ steps.build.outputs.digest }}
- name: Sign Json2Pubsub image
env:
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
run: |
/usr/local/bin/cosign sign --key env://COSIGN_KEY ${{ env.json_image_tag }}@${{ steps.build-json2pubsub.outputs.digest }}