Skip to content

testing

testing #7

Workflow file for this run

name: CI
on:
push:
branches: [main]
env:
REGISTRY: ghcr.io
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -r app/requirements.txt
- name: Run tests
run: |
cd app
python -m pytest test_main.py -v
build-push-update:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
run: |
IMAGE=ghcr.io/$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')/k8s-gitops-platform/demo-api
docker build -t $IMAGE:${{ github.sha }} ./app
docker push $IMAGE:${{ github.sha }}
echo "IMAGE=$IMAGE" >> $GITHUB_ENV
- name: Update image tag in dev values
run: |
sed -i "/name: image.tag/{n;s|value:.*|value: \"${{ github.sha }}\"|}" manifests/argocd/app-dev.yaml
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add manifests/argocd/app-dev.yaml
git commit -m "ci: update dev image tag to ${{ github.sha }}"
git push