Skip to content

simplify the login helper for auth api tests #177

simplify the login helper for auth api tests

simplify the login helper for auth api tests #177

Workflow file for this run

name: lexbox api
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
workflow_dispatch:
push:
paths:
- 'backend/**'
- '.github/workflows/lexbox-api.yaml'
- '.github/workflows/deploy.yaml'
- 'deployment/lexbox-deployment.yaml'
branches:
- main
- develop
pull_request:
paths:
- 'backend/**'
- '.github/workflows/lexbox-api.yaml'
- '.github/workflows/deploy.yaml'
- 'deployment/lexbox-deployment.yaml'
branches:
- main
- develop
env:
PROD_RELEASE: ${{github.ref == vars.PROD_BRANCH}}
jobs:
publish-api:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.setVersion.outputs.VERSION }}
env:
# https://docs.docker.com/develop/develop-images/build_enhancements/
DOCKER_BUILDKIT: 1
steps:
-
uses: actions/checkout@v3
-
name: Set Version
id: setVersion
# set version to date in vYYYY-MM-DD format
run: |
shortSha=$(echo ${{ github.sha }} | cut -c1-8)
echo "VERSION=v$(date --rfc-3339=date):$shortSha" >> ${GITHUB_ENV}
echo "VERSION=v$(date --rfc-3339=date):$shortSha" >> ${GITHUB_OUTPUT}
-
name: Docker meta
id: meta
if: ${{ !env.ACT }}
uses: docker/metadata-action@v4
with:
images: ghcr.io/sillsdev/lexbox-api
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,enable=${{ env.PROD_RELEASE }},value=latest
type=raw,enable=${{ env.PROD_RELEASE }},value=${{ env.VERSION }}
-
name: ghcr.io login
uses: docker/login-action@v2
if: ${{ !env.ACT }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
uses: docker/build-push-action@v4
with:
context: backend
build-args: |
APP_VERSION=${{ env.VERSION }}
push: ${{ !env.ACT && github.repository == 'sillsdev/languageforge-lexbox' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy-api:
uses: ./.github/workflows/deploy.yaml
with:
expected-api-version: ${{ needs.publish-api.outputs.version }}
secrets: inherit
needs: publish-api
if: ${{ github.ref == vars.PROD_BRANCH }}