Merge pull request #15 from texano00/14-add-support-for-arm64 #29
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# GitHub recommends pinning actions to a commit SHA. | |
# To get a newer version, you will need to update the SHA. | |
# You can also reference a tag or branch, but the action may change without warning. | |
name: "[CI/CD] App" | |
on: | |
push: | |
branches: ['main'] | |
paths: | |
- 'app/**' | |
# - '.github/**' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: texano00/urunner | |
jobs: | |
build-and-push-image: | |
if: ${{ !contains(github.event.head_commit.message, '#skip-actions') }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
defaults: | |
run: | |
working-directory: app | |
environment: production | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Lint | |
run: | | |
pylint $(git ls-files '*.py') --fail-under=10 | |
- name: Get version | |
id: metadata | |
run: | | |
version=$(cat .version) | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to container registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.GHCR_USERNAME }} | |
password: ${{ secrets.GHCR_PASSWORD }} | |
registry: ${{ env.REGISTRY }} | |
- name: Check if version already exist | |
id: build_and_push | |
run: | | |
built_image="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.metadata.outputs.version }}" | |
if docker manifest inspect ${built_image} > /dev/null; then | |
echo "already exist -> do not push" | |
exit 1 | |
else | |
echo "does not exist -> going on" | |
fi | |
- name: Build and Push Image | |
uses: docker/build-push-action@v6 | |
with: | |
context: app | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.metadata.outputs.version }} | |
platforms: linux/amd64,linux/arm64/v8,linux/arm/v6,linux/arm/v7 | |
push: true | |