Merge pull request #12 from Sefaria/env-name #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | ||
on: | ||
workflow_dispatch: {} | ||
jobs: | ||
release: | ||
name: Release Chart | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # needed to write releases | ||
outputs: | ||
version: ${{ steps.appVersion.outputs.appVersion }} | ||
if: | | ||
(github.repository == 'sefaria/LLM') | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
# Fetch entire history. Required for chart-releaser; see https://github.com/helm/chart-releaser-action/issues/13#issuecomment-602063896 | ||
fetch-depth: 0 | ||
- name: fetch head of branch to ensure semantic can run | ||
run: git pull origin $GITHUB_REF | ||
- uses: cycjimmy/semantic-release-action@v4 | ||
id: semantic | ||
with: | ||
working_directory: ./app | ||
semantic_version: 18.0.1 | ||
extra_plugins: | | ||
conventional-changelog-conventionalcommits@6.1.0 | ||
semantic-release-monorepo@7.0.5 | ||
@semantic-release/commit-analyzer@9.0.2 | ||
extends: | | ||
semantic-release-monorepo | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: check version was generated | ||
id: appVersion | ||
run: | | ||
if [[ -z "${{ steps.semantic.outputs.new_release_version }}" ]]; then | ||
if [[ -z "$(git tag --points-at HEAD -l 'v*')" ]]; then | ||
echo "No release version available" | ||
exit 1 | ||
else | ||
echo "appVersion=$(git tag --points-at HEAD -l 'v*')" >> $GITHUB_OUTPUT | ||
fi | ||
else | ||
echo "appVersion=${{ steps.semantic.outputs.new_release_version }}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: "Version Info:" | ||
run: echo "${{ steps.appVersion.outputs.appVersion }}" | ||
build: | ||
needs: workflow-check | ||
runs-on: ubuntu-latest | ||
needs: release | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: {{ .needs.release.output.version }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- id: auth | ||
name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: 'projects/${{ secrets.PROD_GKE_PROJECT_ID}}/locations/global/workloadIdentityPools/github/providers/github' | ||
service_account: '${{ secrets.PROD_GKE_SA }}' | ||
- name: Login to GAR | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: us-east1-docker.pkg.dev | ||
username: oauth2accesstoken | ||
password: '${{ steps.auth.outputs.access_token }}' | ||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT | ||
- name: Generate image metadata | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: | | ||
us-east1-docker.pkg.dev/${{ secrets.PROD_GKE_PROJECT }}/containers/sefaria-llm | ||
tags: | | ||
type=ref,event=tag | ||
type=sha,enable=true,priority=100,prefix=sha-,suffix=-${{ steps.date.outputs.date }},format=short | ||
type=sha | ||
type=semver,pattern={{raw}},value=${{needs.release.outputs.version}} | ||
flavor: | | ||
latest=true | ||
- name: build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
build-args: | | ||
TYPE=build-prod | ||
file: ./build/Dockerfile | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |