feat(restaurant): WIP Make user pay for delivery #667
Workflow file for this run
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: Build & Publish | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build-services: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
service: [restaurant, order, gateway, payment, delivery, query, saga] | |
defaults: | |
run: | |
working-directory: ${{ matrix.service }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: corretto | |
- name: Set up Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-version: 8.1.1 | |
- name: Detekt | |
run: ./gradlew detekt | |
- name: Build with Gradle | |
run: ./gradlew build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository }}/${{ matrix.service }} | |
tags: | | |
type=sha | |
type=semver,pattern={{version}} | |
type=raw,value=latest | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./${{ matrix.service }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
build-shared: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: shared | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: corretto | |
- name: Set up Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-version: 8.1.1 | |
- name: Set TAG version | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: echo "VERSION=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV | |
- name: Set SHA version | |
if: "!startsWith(github.ref, 'refs/tags/v')" | |
run: echo "VERSION=sha-${GITHUB_SHA::7}" >> $GITHUB_ENV | |
- name: Publish with Gradle | |
run: ./gradlew -Pversion="${{ env.VERSION }}" publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build-frontend: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: frontend | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Download dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint | |
- name: Type check | |
run: npm run typecheck --if-present | |
- name: Run vitest | |
run: npm run test -- --coverage | |
- name: Copy test env vars | |
run: cp .env.example .env | |
- name: Build | |
run: npm run build | |
# TODO disabled for now because of failing invariant (?) | |
# - name: Cypress run | |
# uses: cypress-io/github-action@v5 | |
# with: | |
# start: npm run start:mocks | |
# wait-on: "http://localhost:8811" | |
# working-directory: ./frontend | |
# env: | |
# PORT: "8811" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository }}/frontend | |
tags: | | |
type=sha | |
type=semver,pattern={{version}} | |
type=raw,value=latest | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./frontend | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64 | |
deploy: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: [ build-services, build-shared, build-frontend ] | |
environment: staging | |
permissions: | |
id-token: write | |
contents: read | |
actions: read | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: azure/setup-kubectl@v3 | |
- uses: azure/k8s-set-context@v3 | |
with: | |
method: kubeconfig | |
kubeconfig: ${{ secrets.KUBECONFIG }} | |
- name: Set TAG version | |
run: echo "VERSION=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV | |
- uses: Azure/k8s-deploy@v4 | |
with: | |
namespace: 'thesis' | |
action: deploy | |
strategy: basic | |
manifests: | | |
k8s/main/restaurant-service-deployment.yaml | |
k8s/main/delivery-service-deployment.yaml | |
k8s/main/order-service-deployment.yaml | |
k8s/main/payment-service-deployment.yaml | |
k8s/main/query-service-deployment.yaml | |
k8s/main/saga-service-deployment.yaml | |
k8s/main/gateway-deployment.yaml | |
k8s/main/frontend-deployment.yaml | |
images: | | |
ghcr.io/bartlomiejrasztabiga/thesis/restaurant:${{ env.VERSION }} | |
ghcr.io/bartlomiejrasztabiga/thesis/delivery:${{ env.VERSION }} | |
ghcr.io/bartlomiejrasztabiga/thesis/order:${{ env.VERSION }} | |
ghcr.io/bartlomiejrasztabiga/thesis/payment:${{ env.VERSION }} | |
ghcr.io/bartlomiejrasztabiga/thesis/query:${{ env.VERSION }} | |
ghcr.io/bartlomiejrasztabiga/thesis/saga:${{ env.VERSION }} | |
ghcr.io/bartlomiejrasztabiga/thesis/gateway:${{ env.VERSION }} | |
ghcr.io/bartlomiejrasztabiga/thesis/frontend:${{ env.VERSION }} |