Skip to content

Attempt to get dockerfiles working again #71

Attempt to get dockerfiles working again

Attempt to get dockerfiles working again #71

Workflow file for this run

name: Deployments
on:
push:
branches:
- main
env:
CI: true
PNPM_CACHE_FOLDER: .pnpm-store
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
create-release-pr:
name: Create release pr
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Fetch tags
run: git fetch --tags origin
- name: Setup bun
uses: oven-sh/setup-bun@v1
- name: Install dependencies
run: bun install
- name: Create release pr / create tags
id: changesets
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.HAISHIN_RUNNER_TOKEN }}
with:
version: bun run version-packages
publish: bun run publish-packages
- name: Echo outputs
run: |
echo "hasChangesets=${{ steps.changesets.outputs.hasChangesets }}"
echo "publishedPackages=${{ steps.changesets.outputs.publishedPackages }}"
echo "publishedPackageNames=${{ toJSON(fromJSON(steps.changesets.outputs.publishedPackages).*['name']) }}"
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
publishedPackageNames: ${{ toJSON(fromJSON(steps.changesets.outputs.publishedPackages).*['name']) }}
publish-frontend:
needs: create-release-pr
name: Publish frontend
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# if: |
# needs.create-release-pr.outputs.hasChangesets == 'false' && (
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/tsconfig') == true ||
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/utils') == true ||
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/transcriber') == true ||
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/frontend') == true
# )
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend
- name: Get git revision
id: git_rev
run: echo "rev=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./apps/frontend/Dockerfile
build-args: |
GIT_REVISION=${{ steps.git_rev.outputs.rev }}
BACKEND_URL=${{ secrets.BACKEND_URL }}
DEEPL_API_KEY=${{ secrets.DEEPL_API_KEY }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
TURBO_TEAM=${{ secrets.TURBO_TEAM }}
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
WS_URL=${{ secrets.WS_URL }}
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
publish-backend:
needs: create-release-pr
name: Publish backend
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# if: |
# needs.create-release-pr.outputs.hasChangesets == 'false' && (
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/tsconfig') == true ||
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/utils') == true ||
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/transcriber') == true ||
# contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/backend') == true
# )
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend
- name: Get git revision
id: git_rev
run: echo "rev=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./apps/backend/Dockerfile
build-args: |
GIT_REVISION=${{ steps.git_rev.outputs.rev }}
TURBO_TEAM=${{ secrets.TURBO_TEAM }}
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cleanup-old-release-tags:
needs: create-release-pr
name: Cleanup old release tags
runs-on: ubuntu-latest
continue-on-error: true
if: |
needs.create-release-pr.outputs.hasChangesets == 'false' && needs.create-release-pr.outputs.publishedPackages != '[]'
strategy:
matrix:
package: ${{ fromJSON(needs.create-release-pr.outputs.publishedPackages).*['name'] }}
steps:
- name: 'Delete release tags'
uses: jay2610/[email protected]
with:
keep_latest: 1
delete_tags: true
delete_tag_pattern: ${{ matrix.package }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}