Skip to content

Commit

Permalink
Create on-push.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilph authored Oct 4, 2024
1 parent edd0813 commit 28258a4
Showing 1 changed file with 199 additions and 0 deletions.
199 changes: 199 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
name: Build and publish Docker image on push

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on: push

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
HTTPSizer_IMAGE_NAME: ${{ github.repository }}
APP_AUTH_IMAGE_NAME: ${{ github.actor }}/umbrel-auth-server
APP_PROXY_IMAGE_NAME: ${{ github.actor }}/umbrel-app-proxy

jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive


# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.4.0'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata for HTTPSizer
id: meta-HTTPSizer
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.HTTPSizer_IMAGE_NAME }}
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata for App Proxy
id: meta-app-proxy
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.APP_PROXY_IMAGE_NAME }}
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata for App Auth
id: meta-app-auth
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.APP_AUTH_IMAGE_NAME }}
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image for HTTPSizer
id: build-and-push-HTTPSizer
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./umbrel-HTTPSizer/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-HTTPSizer.outputs.tags }}
labels: ${{ steps.meta-HTTPSizer.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image for app-proxy
id: build-and-push-app-proxy
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./umbrel-1.2.2/containers/app-proxy/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-app-proxy.outputs.tags }}
labels: ${{ steps.meta-app-proxy.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image for app-auth
id: build-and-push-app-auth
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./umbrel-1.2.2/containers/app-auth/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-app-auth.outputs.tags }}
labels: ${{ steps.meta-app-auth.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image for HTTPSizer
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta-HTTPSizer.outputs.tags }}
DIGEST: ${{ steps.build-and-push-HTTPSizer.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image for app-proxy
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta-app-proxy.outputs.tags }}
DIGEST: ${{ steps.build-and-push-app-proxy.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image for app-auth
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta-app-auth.outputs.tags }}
DIGEST: ${{ steps.build-and-push-app-auth.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 comments on commit 28258a4

Please sign in to comment.