62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
lint-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: pip install ruff mypy -r requirements.txt
|
|
|
|
- name: Lint
|
|
run: ruff check .
|
|
|
|
- name: Type check
|
|
run: mypy check_versions.py --ignore-missing-imports
|
|
|
|
build-push:
|
|
runs-on: ubuntu-latest
|
|
needs: lint-test
|
|
if: github.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push image
|
|
run: |
|
|
if [ -n "${{ secrets.REGISTRY_USERNAME }}" ]; then
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
|
docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
|
|
fi
|
|
docker buildx build \
|
|
--platform linux/amd64 \
|
|
--provenance=false \
|
|
--sbom=false \
|
|
--tag ${{ secrets.REGISTRY_URL }}/k8s-version-tracker:${{ github.sha }} \
|
|
--tag ${{ secrets.REGISTRY_URL }}/k8s-version-tracker:latest \
|
|
--push \
|
|
.
|
|
|
|
- name: Notify Mattermost
|
|
if: always()
|
|
run: |
|
|
STATUS="${{ job.status }}"
|
|
EMOJI=$([ "$STATUS" = "success" ] && echo ":white_check_mark:" || echo ":x:")
|
|
curl -s -X POST "${{ secrets.MATTERMOST_WEBHOOK_URL }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"text\": \"$EMOJI k8s-version-tracker build **$STATUS** — \`${{ github.sha }}\`\"}"
|