refactored to reuse the build workflow
This commit is contained in:
76
.github/workflows/publish.yaml
vendored
76
.github/workflows/publish.yaml
vendored
@@ -3,17 +3,31 @@ name: Build & publish images to the package registry for tags
|
|||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
push:
|
workflow_run:
|
||||||
|
workflows: ["Build"]
|
||||||
branches: [livekit]
|
branches: [livekit]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build_element_call:
|
||||||
name: Build & publish
|
if: ${{ github.event.workflow_run.event == 'release' }}
|
||||||
|
uses: ./.github/workflows/element-call.yaml
|
||||||
|
secrets:
|
||||||
|
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
|
||||||
|
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
||||||
|
SENTRY_URL: ${{ secrets.SENTRY_URL }}
|
||||||
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||||
|
vite_app_version: ${{ github.event.release.tag_name || github.sha }}
|
||||||
|
publish_tarball:
|
||||||
|
name: Publish tarball
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
unix_time: ${{steps.current-time.outputs.unix_time}}
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # required to upload release asset
|
contents: write # required to upload release asset
|
||||||
packages: write
|
packages: write
|
||||||
@@ -21,64 +35,30 @@ jobs:
|
|||||||
- name: Get current time
|
- name: Get current time
|
||||||
id: current-time
|
id: current-time
|
||||||
run: echo "unix_time=$(date +'%s')" >> $GITHUB_OUTPUT
|
run: echo "unix_time=$(date +'%s')" >> $GITHUB_OUTPUT
|
||||||
|
- name: 📥 Download artifact
|
||||||
- name: Check it out
|
uses: actions/download-artifact@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Log in to container registry
|
|
||||||
uses: docker/login-action@5f4866a30a54f16a52d2ecb4a3898e9e424939cf
|
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
username: ${{ github.actor }}
|
run-id: ${{ github.event.workflow_run.id }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
name: build-output
|
||||||
|
path: dist
|
||||||
- name: Yarn cache
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
cache: "yarn"
|
|
||||||
- name: Install dependencies
|
|
||||||
run: "yarn install"
|
|
||||||
- name: Build
|
|
||||||
run: "yarn run build"
|
|
||||||
env:
|
|
||||||
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
|
|
||||||
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
|
||||||
SENTRY_URL: ${{ secrets.SENTRY_URL }}
|
|
||||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
||||||
VITE_APP_VERSION: ${{ github.event.release.tag_name || github.sha }}
|
|
||||||
|
|
||||||
- name: Create Tarball
|
- name: Create Tarball
|
||||||
env:
|
env:
|
||||||
TARBALL_VERSION: ${{ github.event.release.tag_name || github.sha }}
|
TARBALL_VERSION: ${{ github.event.release.tag_name || github.sha }}
|
||||||
run: |
|
run: |
|
||||||
tar --numeric-owner --transform "s/dist/element-call-${TARBALL_VERSION}/" -cvzf element-call-${TARBALL_VERSION}.tar.gz dist
|
tar --numeric-owner --transform "s/dist/element-call-${TARBALL_VERSION}/" -cvzf element-call-${TARBALL_VERSION}.tar.gz dist
|
||||||
|
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@ef09cdac3e2d3e60d8ccadda691f4f1cec5035cb
|
uses: actions/upload-artifact@ef09cdac3e2d3e60d8ccadda691f4f1cec5035cb
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
with:
|
with:
|
||||||
path: "./element-call-*.tar.gz"
|
path: "./element-call-*.tar.gz"
|
||||||
|
publish_docker:
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
needs: publish_tarball
|
||||||
id: meta
|
uses: ./.github/workflows/docker.yaml
|
||||||
uses: docker/metadata-action@1294d94f8ee362ab42b6da04c35f4cd03a0e6af7
|
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
docker_tags: |
|
||||||
tags: |
|
|
||||||
type=sha,format=short,event=branch
|
type=sha,format=short,event=branch
|
||||||
type=semver,pattern=v{{version}}
|
type=semver,pattern=v{{version}}
|
||||||
type=raw,value=latest-ci,enable={{is_default_branch}}
|
type=raw,value=latest-ci,enable={{is_default_branch}}
|
||||||
type=raw,value=latest-ci_${{steps.current-time.outputs.unix_time}},enable={{is_default_branch}}
|
type=raw,value=latest-ci_${{needs.publish_tarball.outputs.unix_time}},enable={{is_default_branch}}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@f8bc7f46003ef0cf98b715743d86c2f1ccd01436
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user