Skip to content

Instantly share code, notes, and snippets.

@jonasfroeller
Last active January 19, 2024 13:55
Show Gist options
  • Save jonasfroeller/3ee00bf46d2c175cfd527fb03a18b7d7 to your computer and use it in GitHub Desktop.
Save jonasfroeller/3ee00bf46d2c175cfd527fb03a18b7d7 to your computer and use it in GitHub Desktop.
CICD Pipeline example (Quarkus backend, Webpack frontend, OracleCloud hosting)
name: CICD Pipeline (Quarkus, Webpack, OracleCloud)
on: [push]
jobs:
test-and-build-frontend:
# permissions: write-all
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 16
- name: Initialize Frontend
run: npm ci
working-directory: frontend
- name: Format/Lint Frontend
run: |
npm run format
npm run lint
working-directory: frontend
- name: Build Frontend
run: npm run build
working-directory: frontend
- name: Archive Frontend
uses: actions/upload-artifact@v3
with:
name: frontend
path: frontend/dist
test-and-build-backend:
# permissions: write-all
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java environment
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: 'maven'
cache-dependency-path: 'backend/pom.xml'
- name: Build Backend
run: |
cd backend
chmod +x mvnw
./mvnw package -Dnative -Dquarkus.native.container-build=true
- name: Archive Backend
uses: actions/upload-artifact@v3
with:
name: backend
path: backend/target
push-frontend-to-docker-hub:
needs: test-and-build-frontend
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: frontend
path: ./frontend/dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push frontend
uses: docker/build-push-action@v5
with:
push: true
tags: <generic name>/frontend:latest
platforms: linux/amd64,linux/arm64
context: ./frontend
push-backend-to-docker-hub:
needs: test-and-build-backend
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: backend
path: ./backend/target
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push backend
uses: docker/build-push-action@v5
with:
push: true
tags: <generic name>/backend:latest
platforms: linux/amd64,linux/arm64
context: ./backend
deploy-frontend-to-oci:
needs: push-frontend-to-docker-hub
runs-on: ubuntu-22.04
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
steps:
- name: Get or create OCIR Repository
uses: oracle-actions/get-ocir-repository@v1.2.1
id: get-ocir-repository
with:
name: <generic name>-frontend
compartment: ${{ secrets.OCI_COMPARTMENT_OCID }}
- name: Log into OCIR
uses: oracle-actions/login-ocir@v1.2.1
id: login-ocir
with:
auth_token: ${{ secrets.OCI_AUTH_TOKEN }}
- name: Tag and push the container image
id: tag-and-push-image
run: |
docker pull <generic name>/frontend:latest
docker tag "<generic name>/frontend:latest" "${{ steps.get-ocir-repository.outputs.repo_path }}:latest"
docker push "${{ steps.get-ocir-repository.outputs.repo_path }}:latest"
deploy-backend-to-oci:
needs: push-backend-to-docker-hub
runs-on: ubuntu-22.04
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
steps:
- name: Get or create OCIR Repository
uses: oracle-actions/get-ocir-repository@v1.2.1
id: get-ocir-repository
with:
name: <generic name>-backend
compartment: ${{ secrets.OCI_COMPARTMENT_OCID }}
- name: Log into OCIR
uses: oracle-actions/login-ocir@v1.2.1
id: login-ocir
with:
auth_token: ${{ secrets.OCI_AUTH_TOKEN }}
- name: Tag and push the container image
id: tag-and-push-image
run: |
docker pull <generic name>/backend:latest
docker tag "<generic name>/backend:latest" "${{ steps.get-ocir-repository.outputs.repo_path }}:latest"
docker push "${{ steps.get-ocir-repository.outputs.repo_path }}:latest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment