test gh env #11
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: Supremo CICD | |
on: | |
push: | |
branches: | |
- dev-howie | |
jobs: | |
build_supremo_app: | |
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 }} | |
REACT_APP_CARLIST_URL: http://140.238.204.249/car-service-redis/cars | |
REACT_APP_CARAPP_LOGINAUTH_URL: http://140.238.204.249/user-service-redis/authn | |
REACT_APP_GET_USER_BY_ID: http://140.238.204.249/user-service-redis/users/ | |
REACT_APP_CREATE_ORDER_API: http://140.238.204.249/order-service/create-order | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get or create an OCIR Repository | |
uses: oracle-actions/[email protected] | |
id: get-ocir-repository | |
with: | |
name: frontend/supremo-reactjs-${GITHUB_REPOSITORY_ID} | |
compartment: ${{ secrets.OCI_COMPARTMENT_OCID }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ steps.get-ocir-repository.outputs.repo_path }} | |
tags: | | |
type=sha,prefix= | |
- name: Login to OCI Container Registry | |
uses: oracle-actions/[email protected] | |
id: login-ocir | |
with: | |
auth_token: ${{ secrets.OCI_AUTH_TOKEN }} | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
working-directory: frontend | |
run: npm list | |
- name: Install dependencies | |
working-directory: frontend | |
run: npm install | |
- name: Build supremo app | |
working-directory: frontend | |
run: CI=false npm run build | |
- name: Build and push image | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: frontend/. | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: ${{ steps.meta.outputs.tags }} | |
push: true | |
deploy_app: | |
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 }} | |
runs-on: ubuntu-latest | |
needs: | |
- build_supremo_app | |
steps: | |
- name: Get or create an OCIR Repository | |
uses: oracle-actions/[email protected] | |
id: get-ocir-repository | |
with: | |
name: frontend/supremo-reactjs-${GITHUB_REPOSITORY_ID} | |
compartment: ${{ secrets.OCI_COMPARTMENT_OCID }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ steps.get-ocir-repository.outputs.repo_path }} | |
tags: | | |
type=sha,prefix= | |
- name: Deploy via OCI DevOps Deployment Pipeline | |
uses: oracle-actions/[email protected] | |
with: | |
command: devops deployment create-pipeline-deployment --pipeline-id ${{ secrets.OCI_DEVOPS_PIPELINE_ID }} --deployment-arguments "{\"items\":[{\"name\":\"IMG\",\"value\":\"${{ steps.get-ocir-repository.outputs.repo_path }}:${{ steps.meta.outputs.version }}\"}]}" | |
silent: true |