Merge pull request #1279 from gulfofmaine/renovate/astral-sh-ruff-pre… #3078
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: CI | |
on: [push] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: buoy-barn-buildx-${{ github.sha }} | |
restore-keys: | | |
buoy-barn-buildx- | |
- name: Cache Docker image | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/myimage.tar | |
key: buoy-barn-image-${{ github.sha }} | |
restore-keys: | | |
buoy-barn-image- | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
continue-on-error: true | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Buoy Barn | |
uses: docker/[email protected] | |
with: | |
context: ./app | |
push: false | |
tags: gmri/neracoos-buoy-barn:latest | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
outputs: type=docker,dest=/tmp/myimage.tar | |
- name: Move Docker Cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
test: | |
name: Unit Tests | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 15 | |
needs: build | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: Cache Docker image | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/myimage.tar | |
key: buoy-barn-image-${{ github.sha }} | |
restore-keys: | | |
buoy-barn-image- | |
- name: Load Docker image | |
run: | | |
docker load --input /tmp/myimage.tar | |
docker image ls -a | |
- name: Test | |
run: make test | |
- name: Send coverage to Codacy (skip coverage if no project token secret) | |
run: | | |
pip install --user codacy-coverage | |
~/.local/bin/python-codacy-coverage -r app/coverage.xml | |
env: | |
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
if: env.CODACY_PROJECT_TOKEN != null | |
deploy: | |
name: Build and Push tagged image to Docker Hub, and update Argo config | |
runs-on: ubuntu-24.04 | |
needs: test | |
environment: | |
name: Buoy Barn via Argo CD | |
url: https://buoy-barn.neracoos.org/admin/ | |
if: | | |
github.repository == 'gulfofmaine/buoy_barn' | |
&& contains(github.ref, 'refs/tags/v') | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: Cache Docker image | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/myimage.tar | |
key: buoy-barn-image-${{ github.sha }} | |
restore-keys: | | |
buoy-barn-image- | |
- name: Load Docker image | |
run: | | |
docker load --input /tmp/myimage.tar | |
docker image ls -a | |
- name: "Login to Docker Hub" | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get tag name | |
uses: olegtarasov/[email protected] | |
id: tagName | |
- name: Tag Docker image | |
run: docker tag gmri/neracoos-buoy-barn gmri/neracoos-buoy-barn:${{ steps.tagName.outputs.tag }} | |
- name: Push Docker image | |
run: docker push gmri/neracoos-buoy-barn:${{ steps.tagName.outputs.tag }} | |
- name: Make GitOps directory | |
run: mkdir gitops | |
- name: Clone GitOps config repo | |
run: git clone "https://[email protected]/gulfofmaine/neracoos-aws-cd.git" | |
working-directory: ./gitops | |
env: | |
GITOPS_TOKEN: ${{ secrets.GITOPS_TOKEN }} | |
- name: Update GitOps config repo | |
working-directory: ./gitops/neracoos-aws-cd | |
run: | | |
sed -i 's/?ref=.\+/?ref=${{ steps.tagName.outputs.tag }}/' overlays/buoy-barn/kustomization.yaml | |
sed -i 's/newTag: .\+/newTag: ${{ steps.tagName.outputs.tag }}/' overlays/buoy-barn/kustomization.yaml | |
git config --global user.email '[email protected]' | |
git config --global user.name 'NERACOOS Buoy Barn CI' | |
git diff --exit-code && echo 'Already Deployed' || (git commit -am 'Upgrade Buoy Barn to ${{ steps.tagName.outputs.tag }}' && git push) | |
- name: Create Sentry Release | |
uses: getsentry/[email protected] | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: prod | |
version: ${{ steps.tagName.outputs.tag }} |