|
|
|
@@ -19,7 +19,6 @@ env:
|
|
|
|
|
IMAGE_NAME: cartsnitch/cartsnitch
|
|
|
|
|
AUTH_IMAGE_NAME: cartsnitch/auth
|
|
|
|
|
RECEIPTWITNESS_IMAGE_NAME: cartsnitch/receiptwitness
|
|
|
|
|
API_IMAGE_NAME: cartsnitch/api
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
lint:
|
|
|
|
@@ -62,7 +61,6 @@ jobs:
|
|
|
|
|
|
|
|
|
|
build-and-push:
|
|
|
|
|
runs-on: runners-cartsnitch
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
needs: [lint, test, e2e]
|
|
|
|
|
outputs:
|
|
|
|
|
calver_tag: ${{ steps.calver.outputs.version }}
|
|
|
|
@@ -88,13 +86,6 @@ jobs:
|
|
|
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
|
echo "CalVer tag: $VERSION"
|
|
|
|
|
|
|
|
|
|
- name: Log in to Docker Hub
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
|
|
- name: Log in to GHCR
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
@@ -132,7 +123,6 @@ jobs:
|
|
|
|
|
|
|
|
|
|
build-and-push-auth:
|
|
|
|
|
runs-on: runners-cartsnitch
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
needs: [lint, test, e2e]
|
|
|
|
|
outputs:
|
|
|
|
|
calver_tag: ${{ steps.calver.outputs.version }}
|
|
|
|
@@ -157,13 +147,6 @@ jobs:
|
|
|
|
|
fi
|
|
|
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
- name: Log in to Docker Hub
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
|
|
- name: Log in to GHCR
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
@@ -193,7 +176,6 @@ jobs:
|
|
|
|
|
|
|
|
|
|
build-and-push-receiptwitness:
|
|
|
|
|
runs-on: runners-cartsnitch
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
needs: [lint, test]
|
|
|
|
|
outputs:
|
|
|
|
|
calver_tag: ${{ steps.calver.outputs.version }}
|
|
|
|
@@ -213,13 +195,6 @@ jobs:
|
|
|
|
|
else BUILD_NUM=$(echo "$EXISTING" | sed "s/v${DATE_TAG}\.//"); VERSION="${DATE_TAG}.$((BUILD_NUM + 1))"; fi
|
|
|
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
- name: Log in to Docker Hub
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
|
|
- name: Log in to GHCR
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
@@ -247,65 +222,9 @@ jobs:
|
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
|
|
|
|
|
|
build-and-push-api:
|
|
|
|
|
runs-on: runners-cartsnitch
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
needs: [lint, test]
|
|
|
|
|
outputs:
|
|
|
|
|
calver_tag: ${{ steps.calver.outputs.version }}
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
with:
|
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
|
|
- name: Generate CalVer tag
|
|
|
|
|
id: calver
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
run: |
|
|
|
|
|
DATE_TAG=$(date -u +%Y.%m.%d)
|
|
|
|
|
EXISTING=$(git tag -l "v${DATE_TAG}*" | sort -V | tail -1)
|
|
|
|
|
if [ -z "$EXISTING" ]; then VERSION="$DATE_TAG"
|
|
|
|
|
elif [ "$EXISTING" = "v${DATE_TAG}" ]; then VERSION="${DATE_TAG}.2"
|
|
|
|
|
else BUILD_NUM=$(echo "$EXISTING" | sed "s/v${DATE_TAG}\.//"); VERSION="${DATE_TAG}.$((BUILD_NUM + 1))"; fi
|
|
|
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
- name: Log in to Docker Hub
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
|
|
- name: Log in to GHCR
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
|
|
- name: Extract metadata (API)
|
|
|
|
|
id: meta
|
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
|
with:
|
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}
|
|
|
|
|
tags: |
|
|
|
|
|
type=sha,prefix=sha-
|
|
|
|
|
type=raw,value=${{ steps.calver.outputs.version }},enable=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
|
|
|
|
|
|
|
|
- name: Build and push API Docker image
|
|
|
|
|
uses: docker/build-push-action@v6
|
|
|
|
|
with:
|
|
|
|
|
context: .
|
|
|
|
|
file: ./api/Dockerfile
|
|
|
|
|
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
|
|
|
|
|
|
deploy-dev:
|
|
|
|
|
runs-on: runners-cartsnitch
|
|
|
|
|
needs: [build-and-push, build-and-push-auth, build-and-push-receiptwitness, build-and-push-api]
|
|
|
|
|
needs: [build-and-push, build-and-push-auth, build-and-push-receiptwitness]
|
|
|
|
|
if: always() && !cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
|
steps:
|
|
|
|
|
- name: Generate GitHub App token
|
|
|
|
@@ -331,7 +250,7 @@ jobs:
|
|
|
|
|
- name: Install kustomize
|
|
|
|
|
uses: imranismail/setup-kustomize@v2
|
|
|
|
|
|
|
|
|
|
- name: Update frontend image tag
|
|
|
|
|
- name: Update cartsnitch image tag
|
|
|
|
|
if: needs.build-and-push.result == 'success'
|
|
|
|
|
run: |
|
|
|
|
|
cd infra/apps/overlays/dev
|
|
|
|
@@ -349,17 +268,11 @@ jobs:
|
|
|
|
|
cd infra/apps/overlays/dev
|
|
|
|
|
kustomize edit set image ghcr.io/cartsnitch/receiptwitness:${{ needs.build-and-push-receiptwitness.outputs.calver_tag }}
|
|
|
|
|
|
|
|
|
|
- name: Update api image tag
|
|
|
|
|
if: needs.build-and-push-api.result == 'success'
|
|
|
|
|
run: |
|
|
|
|
|
cd infra/apps/overlays/dev
|
|
|
|
|
kustomize edit set image ghcr.io/cartsnitch/api:${{ needs.build-and-push-api.outputs.calver_tag }}
|
|
|
|
|
|
|
|
|
|
- name: Commit and push to infra
|
|
|
|
|
run: |
|
|
|
|
|
cd infra
|
|
|
|
|
git config user.name "cartsnitch-ci[bot]"
|
|
|
|
|
git config user.email "cartsnitch-ci[bot]@users.noreply.github.com"
|
|
|
|
|
git add apps/overlays/dev/kustomization.yaml
|
|
|
|
|
git commit -m "ci(dev): update cartsnitch, auth, receiptwitness, and api images"
|
|
|
|
|
git commit -m "ci(dev): update cartsnitch, auth, and receiptwitness images"
|
|
|
|
|
git push origin main
|
|
|
|
|