feat: add app monitoring, API filtering & improving ci #15
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: Docker Image CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
set-environment: | |
name: Set environment | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get the latest code | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ secrets.PHP_VERSION }} | |
extensions: none | |
coverage: none | |
tools: none | |
- name: Set App Version | |
run: | | |
VERSION=$(php -r "include 'src/Constants.php'; echo App\Constants::VERSION;") | |
echo "APP_VERSION=$VERSION" > $GITHUB_WORKSPACE/.env | |
amd-build: | |
name: Build & Deploy (AMD) | |
needs: set-environment | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get the latest code | |
uses: actions/checkout@v4 | |
- name: Load environment | |
run: source $GITHUB_WORKSPACE/.env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to container registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }} | |
password: ${{ secrets.CONTAINER_REGISTRY_PWD }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64 | |
build-args: VERSION=${{ secrets.PHP_VERSION }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: waistlineapi/waistline-api:${{ env.APP_VERSION }}-amd64 | |
arm-build: | |
name: Build & Deploy (ARM) | |
if: github.event_name != 'pull_request' | |
needs: set-environment | |
runs-on: buildjet-4vcpu-ubuntu-2204-arm | |
steps: | |
- name: Get the latest code | |
uses: actions/checkout@v4 | |
- name: Load environment | |
run: source $GITHUB_WORKSPACE/.env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to container registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }} | |
password: ${{ secrets.CONTAINER_REGISTRY_PWD }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/arm64 | |
build-args: VERSION=${{ secrets.PHP_VERSION }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: waistlineapi/waistline-api:${{ env.APP_VERSION }}-arm64 | |
combine-manifest: | |
name: Combine the manifests | |
if: github.event_name != 'pull_request' | |
needs: | |
- amd-build | |
- arm-build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Load environment | |
run: source $GITHUB_WORKSPACE/.env | |
- name: Login to container registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }} | |
password: ${{ secrets.CONTAINER_REGISTRY_PWD }} | |
- name: Combine the manifests | |
uses: int128/docker-manifest-create-action@v2 | |
with: | |
tags: waistlineapi/waistline-api:latest | |
sources: | | |
waistlineapi/waistline-api:${{ env.APP_VERSION }}-amd64 | |
waistlineapi/waistline-api:${{ env.APP_VERSION }}-arm64 |