Skip to content

Commit

Permalink
Merge pull request #26 from matrix-org/bbz/update-ghas
Browse files Browse the repository at this point in the history
Workflow improvements
  • Loading branch information
benbz authored May 26, 2023
2 parents df166f5 + 109669e commit 30faedc
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 396 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/docker-publish-individual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Docker Publish Jitsi Component

on:
workflow_call:
inputs:
folder:
required: true
type: string
secrets:
github-token:
required: true

env:
REGISTRY: ghcr.io
REGISTRY_BASE_PATH: ghcr.io/${{ github.repository }}
BASE_TAG: ${{ github.ref_name }}

jobs:
build-push:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.github-token }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_BASE_PATH }}/${{ inputs.folder }}
# Turn off auto-latest, as we want to exclude openshift tags from that
flavor: |
latest=false
# 1-3. Generate the default docker tags, 4. generate latest if git tag is on the default branch, 5. generate openshift-latest if git tag is on the openshift branch
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=ref,event=tag,value=latest,enable={{is_default_branch}}
type=ref,event=tag,value=openshift-latest,enable=${{ github.ref == 'refs/heads/openshift' }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: "${{ inputs.folder }}"
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"BASE_TAG=${{ env.BASE_TAG }}"
"JITSI_REPO=${{ env.REGISTRY_BASE_PATH }}"
if: contains(github.ref_name, '/merge') == false

- name: Build and push Docker image for PR
uses: docker/build-push-action@v4
with:
context: "${{ inputs.folder }}"
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"BASE_TAG=${{ github.base_ref }}"
"JITSI_REPO=${{ env.REGISTRY_BASE_PATH }}"
if: contains(github.ref_name, '/merge')
Loading

0 comments on commit 30faedc

Please sign in to comment.