Skip to content

escape sed

escape sed #53

Workflow file for this run

on:
push:
branches:
- refine_workflow
# pull_request:
# branches:
# - main
jobs:
build:
environment: preview
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: 18 # Use Node.js 18 here
- name: Install Dependencies
run: npm install
- name: Build App
env:
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
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Get Commit Hash
id: commit_hash
uses: prompt/actions-commit-hash@v3
- uses: docker/setup-buildx-action@v3
- name: Build and Push (Docker Image)
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.IMG_NAME }}:latest
${{ 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]
environment: preview
runs-on: ubuntu-latest
steps:
- name: Get Commit Hash
id: commit_hash
uses: prompt/actions-commit-hash@v3
- name: Show Commit Hash Digest
run: echo ${{ steps.commit_hash.outputs.short }}
- name: Configure Git User as GitHub Actions Bot
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Checkout
uses: actions/checkout@v4
with:
repository: "${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}"
token: ${{ secrets.DOCS_NEXT_CHARTS_TOKEN }}
- name: Show Contents
run: ls -latr
- 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: ${{ 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
git push origin main