Skip to content

Merge pull request #2277 from edenmind/YunusAndreasson/issue2275 #449

Merge pull request #2277 from edenmind/YunusAndreasson/issue2275

Merge pull request #2277 from edenmind/YunusAndreasson/issue2275 #449

name: build-push-and-deploy-containers
on:
push:
branches: [main]
jobs:
build-push-and-deploy-containers:
runs-on: ubuntu-latest
steps:
- name: πŸ— Prepare Meta Data for Build
id: prep
run: |
branch=${GITHUB_REF##*/}
sha=${GITHUB_SHA::8}
fullsha=${GITHUB_SHA}
ts=$(date +%s)
echo "::set-output name=BUILD_ID::${branch}-${sha}-${ts}"
echo "::set-output name=GIT_SHA::${fullsha}"
- name: πŸ— Checkout
uses: actions/checkout@v4
- name: πŸ— Set up QEMU
uses: docker/setup-qemu-action@v3
- name: πŸ— Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: πŸ— Docker Login
uses: docker/login-action@v3
with:
registry: registry.digitalocean.com/openarabic/
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: πŸ— Install Helm
uses: Azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION_TO_INSTALL }}
env:
HELM_VERSION_TO_INSTALL: 3.12.0
- name: πŸ— Login to Registry With Helm
run: |
helm registry login registry.digitalocean.com/openarabic --username ${{ secrets.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKERHUB_PASSWORD }}
- name: πŸ”Ž Replace Commit SHA in Footer in Web
uses: cschleiden/replace-tokens@v1
with:
files: '["web/src/components/footer.js"]'
tokenPrefix: "@("
tokenSuffix: ")@"
env:
GIT_SHA: ${{ steps.prep.outputs.GIT_SHA }}
- name: πŸ“¦ Build and Push API to Container Registry
uses: docker/build-push-action@v5
with:
file: ./api/Dockerfile
tags: registry.digitalocean.com/openarabic/api:${{ steps.prep.outputs.BUILD_ID }}
context: ./api
push: true
- name: πŸ“¦ Build and Push Web to Container Registry
uses: docker/build-push-action@v5
with:
file: ./web/Dockerfile
tags: registry.digitalocean.com/openarabic/web:${{ steps.prep.outputs.BUILD_ID }}
context: ./web
push: true
secrets: |
"REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}"
"REACT_APP_KEY=${{ secrets.REACT_APP_KEY }}"
"REACT_APP_GOOGLE_API_KEY=${{ secrets.REACT_APP_GOOGLE_API_KEY }}"
- name: πŸ”Ž Replace SHA Tag for Containers and Helm Chart
uses: cschleiden/replace-tokens@v1
with:
files: '["package/**/*.yaml"]'
env:
BUILD_ID: ${{ steps.prep.outputs.BUILD_ID }}
# https://github.com/marketplace/actions/kubescape
- name: πŸ”Ž Lint and Package
working-directory: ./package
run: ./build.sh
- name: πŸš€ Publish Chart to Registry
working-directory: ./package
env:
HELM_EXPERIMENTAL_OCI: 1
run: |
helm push dist/open-arabic-helm*.tgz oci://registry.digitalocean.com/openarabic