Skip to content

Use build targets to reduce unneeded builds #11

Use build targets to reduce unneeded builds

Use build targets to reduce unneeded builds #11

name: Integrate changes and deploy
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
workflow_call:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs
inputs:
image-tag-app:
type: string
required: true
image-tag-proxy:
type: string
required: true
image-tag-next-app:
type: string
required: true
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecrets
secrets:
kube-context:
required: true
image-repo-username:
required: true
image-repo-password:
required: true
jobs:
integrate:
runs-on: ubuntu-latest
env:
# https://docs.docker.com/develop/develop-images/build_enhancements/
DOCKER_BUILDKIT: 1
steps:
-
uses: actions/checkout@v3
-
run: |
docker --version
docker compose version
-
name: Establish image name
id: image
run: |
echo "NAMESPACE=sillsdev/web-languageforge" >> $GITHUB_OUTPUT
echo "TAG_APP=${{ inputs.image-tag-app }}" >> $GITHUB_OUTPUT
echo "TAG_PROXY=${{ inputs.image-tag-proxy }}" >> $GITHUB_OUTPUT
echo "TAG_NEXT_APP=${{ inputs.image-tag-next-app }}" >> $GITHUB_OUTPUT
echo "LFMERGE_NAMESPACE=ghcr.io/sillsdev/lfmerge" >> $GITHUB_OUTPUT
# Get LfMerge tag from Dockerfile, fallback to "latest" as default if that fails
TAG_LFMERGE=$(head -n 1 docker/lfmerge/Dockerfile | cut -d: -f2)
TAG_LFMERGE=${TAG_LFMERGE:-latest}
echo "TAG_LFMERGE=${TAG_LFMERGE}" >> $GITHUB_OUTPUT
-
uses: actions/setup-node@v4
with:
node-version: '22.2.0'
cache: 'pnpm'
-
run: pnpm ci
-

Check failure on line 63 in .github/workflows/integrate-and-deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/integrate-and-deploy.yml

Invalid workflow file

You have an error in your yaml syntax on line 63
name: Prep for production build of legacy app
# docker compose build doesn't allow passing a `--target` parameter, so we have to replace the target in docker-compose.yml
run: "sed -i 's/target: development/target: production/g'" docker-compose.yml
-
name: Build legacy app
run: docker compose build --build-arg ENVIRONMENT=production --build-arg BUILD_VERSION=${{ steps.image.outputs.TAG_APP }} app
-
name: Verify version stamping
run: |
docker run --rm lf-app head build-version.txt version.php
docker run --rm lf-app head version.php | grep -q ${{ steps.image.outputs.TAG_APP }}
-
name: Build "next" images
run: make build-next
-
name: Unit Tests
run: make unit-tests-ci
-
name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.image-repo-username }}
password: ${{ secrets.image-repo-password }}
-
name: Tag images
run: |
docker tag lf-app ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG_APP }}
docker tag lf-next-proxy ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG_PROXY }}
docker tag lf-next-app ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG_NEXT_APP }}
-
run: docker images
-
name: Publish images
run: docker push --all-tags ${{ steps.image.outputs.NAMESPACE }}
outputs:
IMAGE_APP: ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG_APP }}
IMAGE_PROXY: ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG_PROXY }}
IMAGE_NEXT_APP: ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG_NEXT_APP }}
IMAGE_LFMERGE: ${{ steps.image.outputs.LFMERGE_NAMESPACE }}:${{ steps.image.outputs.TAG_LFMERGE }}
e2e-tests:
uses: ./.github/workflows/e2e-tests.yml
deploy:
runs-on: [self-hosted, languageforge]
needs: [integrate, e2e-tests]
steps:
-
uses: sillsdev/common-github-actions/install-kubectl@v1
-
run: |
kubectl --context ${{ secrets.kube-context }} -n languageforge set image deployment/app app=${{ needs.integrate.outputs.IMAGE_APP }}
kubectl --context ${{ secrets.kube-context }} -n languageforge set image deployment/next-proxy next-proxy=${{ needs.integrate.outputs.IMAGE_PROXY }}
kubectl --context ${{ secrets.kube-context }} -n languageforge set image deployment/next-app next-app=${{ needs.integrate.outputs.IMAGE_NEXT_APP }}
kubectl --context ${{ secrets.kube-context }} -n languageforge set image deployment/lfmerge lfmerge=${{ needs.integrate.outputs.IMAGE_LFMERGE }}