Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dipeshrath committed Aug 13, 2024
1 parent 3a9ffab commit 9195a50
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 32 deletions.
43 changes: 38 additions & 5 deletions fn-ci-cd-deployment-pipeline/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
# CI/CD pipeline for OCI function deployment using Fn CLI

## Introduction
This repository contains custom scripts developed and published in public blogs by Oracle Cloud Engineering Services for OCI Infrastructure Automation.
This is a reference yaml as an action workflow to build and deploy the OCI function using FN CLI.

It will help to update or enhance the code also easy to clone and reuse by community.
### Pipeline Definition
- [oci-fn-build.yml](./oci-fn-build.yml)
- [oci-fn-deploy.yml](./oci-fn-deploy.yml)

### Prerequisites
Custom code from published blogs only must be contributed here.
### Build and Deploy Pipeline

Deploy a function using the Fn Project CLI, the function is built as a Docker image and pushed to a specified Docker registry.

- Provide value for non senstive information as an input and update during runtime.

```
OCI_FN_NAME
OCI_FN_APP
OCI_FN_COMPARTMENT
OCI_FN_IMAGE
````
- Create environment variables for other non senstive information.
```
OCI_TENANCY_NAME
OCI_FN_REGISTRY
OCI_FN_API_URL
OCI_FN_USER_NAME
OCI_FN_OCIR
```
- Create secrets for all senstive information to use in the pipeline.
```
OCI_CLI_USER
OCI_CLI_FINGERPRINT
OCI_CLI_TENANCY
OCI_CLI_REGION
OCI_CLI_KEY_CONTENT
```
OCI Functions pulls the function's Docker image from the specified Docker registry, runs it as a Docker container, and executes the function.
## License
Copyright (c) 2022 Oracle and/or its affiliates.
Copyright (c) 2024 Oracle and/or its affiliates.
Licensed under the Universal Permissive License (UPL), Version 1.0.
Expand Down
24 changes: 9 additions & 15 deletions fn-ci-cd-deployment-pipeline/oci-fn-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,17 @@ on:
# but only for the main branch
workflow_dispatch:
inputs:
OCI_FN_APP:
description: Function app name
default: dip-str
OCI_FN_COMPARTMENT:
description: Function compartment
default: ocid1.compartment.oc1..aaaaaaaanovmfmmnonjjyxeq4jyghszj2eczlrkgj5svnxrtrvqvfhmbubeq
OCI_FN_NAME:
description: Function Name
default: oci-logs-stream
OCI_FN_IMAGE:
description: OCIR Image to use for Function
default: bom.ocir.io/bmpmwyacrlcj/repodip1/oci-logs-stream:0.0.19
default: ocid1.compartment.oc1....

jobs:
# This workflow contains a single job called "build"
Build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
Expand All @@ -37,7 +29,7 @@ jobs:
echo "user=${{secrets.OCI_CLI_USER}}" >> ~/.oci/config
echo "fingerprint=${{secrets.OCI_CLI_FINGERPRINT}}" >> ~/.oci/config
echo "tenancy=${{secrets.OCI_CLI_TENANCY}}" >> ~/.oci/config
echo "region=${{secrets.OCI_CLI_REGION}}" >> ~/.oci/config
echo "region=${{vars.OCI_CLI_REGION}}" >> ~/.oci/config
echo "${{secrets.OCI_CLI_KEY_CONTENT}}" >> ~/.oci/key.pem
echo "key_file=~/.oci/key.pem" >> ~/.oci/config
Expand All @@ -60,16 +52,18 @@ jobs:
curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh
- name: 'Docker login'
run: docker login -u ${{ vars.OCI_FN_USER }} -p ${{ secrets.OCI_CLI_AUTH_TOKEN }} ${{ vars.OCI_FN_OCIR }}
run: docker login -u ${{ vars.OCI_FN_USER_NAME }} -p ${{ secrets.OCI_CLI_AUTH_TOKEN }} ${{ vars.OCI_FN_OCIR }}

- name: 'Setting up Fn context'
run: |
fn create context dipeshrathod60 --provider oracle
fn use context dipeshrathod60
fn create context ${{ vars.OCI_TENANCY_NAME }} --provider oracle
fn use context ${{ vars.OCI_TENANCY_NAME }}
fn update context registry ${{ vars.OCI_FN_REGISTRY }}
fn update context oracle.compartment-id ${{ inputs.OCI_FN_COMPARTMENT }}
fn update context api-url ${{ vars.OCI_FN_API_URL }}
- name: 'Build Image for OCI Function'
run: fn build --verbose

- name: 'Push image to OCI Registry'
run: fn push --verbose
22 changes: 10 additions & 12 deletions fn-ci-cd-deployment-pipeline/oci-fn-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ on:
# but only for the main branch
workflow_dispatch:
inputs:
OCI_FN_NAME:
description: Function Name
default: demo-function
OCI_FN_APP:
description: Function app name
default: dip-str
default: demo-function-app
OCI_FN_COMPARTMENT:
description: Function compartment
default: ocid1.compartment.oc1..aaaaaaaanovmfmmnonjjyxeq4jyghszj2eczlrkgj5svnxrtrvqvfhmbubeq
OCI_FN_NAME:
description: Function Name
default: oci-logs-stream
default: ocid1.compartment.oc1....
OCI_FN_IMAGE:
description: OCIR Image to use for Function
default: bom.ocir.io/bmpmwyacrlcj/repodip1/oci-logs-stream:0.0.19
OCI_TENANCY_NAME:
description: Tenancy Name
default: dipeshrathod60
default: bom.ocir.io/<imagepath-oci:0.0.2>

jobs:
# This workflow contains a single job called "build"
Deploy:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand Down Expand Up @@ -63,8 +61,8 @@ jobs:
- name: 'Setting up Fn context'
run: |
fn create context ${{ inputs.OCI_TENANCY_NAME }} --provider oracle
fn use context ${{ inputs.OCI_TENANCY_NAME }}
fn create context ${{ vars.OCI_TENANCY_NAME }} --provider oracle
fn use context ${{ vars.OCI_TENANCY_NAME }}
fn update context registry ${{ vars.OCI_FN_REGISTRY }}
fn update context oracle.compartment-id ${{ inputs.OCI_FN_COMPARTMENT }}
fn update context api-url ${{ vars.OCI_FN_API_URL }}
Expand Down

0 comments on commit 9195a50

Please sign in to comment.