Skip to content

Commit

Permalink
Merge pull request #8 from akyriako/refine_workflow
Browse files Browse the repository at this point in the history
Refine workflow
  • Loading branch information
akyriako authored Jul 11, 2024
2 parents ca37909 + 108053b commit edf22a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 39 deletions.
53 changes: 19 additions & 34 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
# branches:
# - main
jobs:
build-app:
build:
environment: preview
runs-on: ubuntu-latest

Expand All @@ -24,21 +24,12 @@ jobs:

- name: Build App
env:
TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }}
TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }}
TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }}
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
REACT_APP_TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }}
REACT_APP_TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }}
REACT_APP_TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }}
REACT_APP_TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_SEARCH_KEY }}
run: npm run build

build-push-docker:
environment: preview
runs-on: ubuntu-latest
needs: build-app

steps:
- name: Checkout
uses: actions/checkout@v2


- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -62,13 +53,13 @@ jobs:
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.IMG_NAME }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.IMG_NAME }}:${{ steps.commit_hash.outputs.short }}
${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.IMG_NAME }}:${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}
# - name: Image Digest
# run: echo ${{ steps.docker_build.outputs.digest }}

update-helm-charts:
needs: [build-app, build-push-docker]
needs: [build]
environment: preview
runs-on: ubuntu-latest

Expand All @@ -93,28 +84,22 @@ jobs:

- name: Show Contents
run: ls -latr

- name: Update Charts
- name: Update Charts and Commit Changes
id: update_charts
env:
image: ${{ secrets.DOCKERHUB_USERNAME }}\/${{ vars.IMG_NAME }}
run: |
# docusaurus
sed -i 's/^version: .*/version: ${{ vars.APP_VERSION }}.${{github.run_number}}/' ./charts/docusaurus/Chart.yaml
sed -i 's/^appVersion: .*/appVersion: ${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}/' ./charts/docusaurus/Chart.yaml
sed -i 's/^tag: .*/tag: ${{ steps.commit_hash.outputs.short }}/' ./charts/docusaurus/values.yaml
sed -i 's/^typesenseHost: .*/typesenseHost: ${{ vars.TYPESENSE_HOST }}/' ./charts/docusaurus/values.yaml
sed -i 's/^typesensePort: .*/typesensePort: ${{ vars.TYPESENSE_PORT }}/' ./charts/docusaurus/values.yaml
sed -i 's/^typesenseProtocol: .*/typesenseProtocol: ${{ vars.TYPESENSE_PROTOCOL }}/' ./charts/docusaurus/values.yaml
sed -i 's/^typesenseSearchApiKey: .*/typesenseSearchApiKey: ${{ secrets.TYPESENSE_SEARCH_KEY }}/' ./charts/docusaurus/values.yaml
sed -i 's/^elbId: .*/elbId: ${{ vars.DOCS_NEXT_ELB_ID }}/' ./charts/docusaurus/values.yaml
sed -i 's/^host: .*/host: ${{ vars.DOCS_NEXT_HOST }}/' ./charts/docusaurus/values.yaml
# typesense
sed -i 's/^version: .*/version: ${{ vars.APP_VERSION }}.${{github.run_number}}/' ./charts/typesense/Chart.yaml
sed -i 's/^appVersion: .*/appVersion: ${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}/' ./charts/typesense/Chart.yaml
sed -i 's/^apiKey: .*/apiKey: ${{ secrets.TYPESENSE_API_KEY }}/' ./charts/typesense/values.yaml
sed -i 's/^host: .*/host: ${{ vars.TYPESENSE_HOST }}/' ./charts/typesense/values.yaml
sed -i 's/^port: .*/port: ${{ vars.TYPESENSE_PORT }}/' ./charts/typesense/values.yaml
sed -i 's/^elbId: .*/elbId: ${{ vars.TYPESENSE_ELB_ID }}/' ./charts/typesense/values.yaml
sed -i 's/^externalUrl: .*/externalUrl: ${{ vars.DOCS_NEXT_HOST }}/' ./charts/typesense/values.yaml
sed -i 's/^tag: .*/tag: ${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}/' ./charts/docusaurus/values.yaml
sed -i 's/^image: .*/image: ${{ env.image }}/' ./charts/docusaurus/values.yaml
cat ./charts/docusaurus/Chart.yaml
echo ""
echo "---"
echo ""
cat ./charts/docusaurus/values.yaml
# commit and push
git commit -am "Automatic commit from GitHub Actions triggered by action #${{github.run_number}}"
git remote set-url origin https://${{ secrets.DOCS_NEXT_CHARTS_TOKEN }}@github.com/${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}.git
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ COPY . .
EXPOSE 80

CMD ["npm", "run", "serve"]

8 changes: 4 additions & 4 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ const config: Config = {
typesenseServerConfig: {
nodes: [
{
host: process.env.TYPESENSE_HOST,
port: process.env.TYPESENSE_PORT,
protocol: process.env.TYPESENSE_PROTOCOL,
host: process.env.REACT_APP_TYPESENSE_HOST,
port: process.env.REACT_APP_TYPESENSE_PORT,
protocol: process.env.REACT_APP_TYPESENSE_PROTOCOL,
},
],
apiKey: process.env.TYPESENSE_API_KEY,
apiKey: process.env.REACT_APP_TYPESENSE_API_KEY,
},

// Optional: Typesense search parameters: https://typesense.org/docs/0.24.0/api/search.html#search-parameters
Expand Down

0 comments on commit edf22a1

Please sign in to comment.