BuildEngine CI #210
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: BuildEngine CI | |
on: | |
push: | |
branches: [master, develop, github-builds] | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: "Log Level" | |
required: true | |
default: "warning" | |
tags: | |
description: "Tags" | |
schedule: | |
- cron: "0 0 * * 0" # weekly | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get environment info | |
run: | | |
echo Docker version | |
docker --version | |
echo | |
echo Env | |
env | |
- name: Setup local.env | |
run: | | |
echo "COMPOSER_AUTH={\"github-oauth\":{\"github.com\":\""${{ secrets.GITHUB_TOKEN }}\""}}" > local.env | |
- name: Tests | |
run: | | |
make test | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Determine branch tag | |
id: branch | |
run: | | |
if [[ "${GITHUB_HEAD_REF}" != "" ]]; then BRANCH="${GITHUB_HEAD_REF}"; else BRANCH="${GITHUB_REF_NAME}"; fi | |
case $BRANCH in develop) DOCKER_TAG="staging" ;; master) DOCKER_TAG="production" ;; *) DOCKER_TAG="${BRANCH//\//-}" ;; esac | |
echo "DockerTag=${DOCKER_TAG}" >> $GITHUB_OUTPUT | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
push: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch') && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/github-builds') }} | |
tags: | | |
ghcr.io/sillsdev/appbuilder-buildengine-api:${{ steps.branch.outputs.DockerTag }} | |
context: . | |
- name: Clean up older packages | |
uses: actions/delete-package-versions@v4 | |
with: | |
package-name: "appbuilder-buildengine-api" | |
package-type: "container" | |
min-versions-to-keep: 6 | |
delete-only-untagged-versions: "true" |