Skip to content

Commit 4829318

Browse files
committed
Add GitHub Actions workflow for OCI deployment
This workflow automates the deployment to Oracle Cloud Infrastructure. It includes steps for building and pushing Docker images and deploying them to an OCI Container Instance. Secrets are used for secure authentication and configuration.
1 parent d8df3de commit 4829318

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/deploy-to-oci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy to Oracle Cloud Infrastructure
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
build-and-deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v2
17+
18+
- name: Login to Oracle Cloud Infrastructure Registry
19+
uses: docker/login-action@v2
20+
with:
21+
registry: ${{ secrets.OCI_REGISTRY }}
22+
username: ${{ secrets.OCI_USERNAME }}
23+
password: ${{ secrets.OCI_AUTH_TOKEN }}
24+
25+
- name: Build and push Docker image
26+
uses: docker/build-push-action@v4
27+
with:
28+
context: .
29+
push: true
30+
tags: ${{ secrets.OCI_REGISTRY }}/${{ secrets.OCI_NAMESPACE }}/adminhubapi:${{ github.sha }}
31+
32+
- name: Install OCI CLI
33+
run: |
34+
curl -L -O https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh
35+
chmod +x install.sh
36+
./install.sh --accept-all-defaults
37+
echo "$HOME/lib/oracle-cli/bin" >> $GITHUB_PATH
38+
39+
- name: Configure OCI CLI
40+
run: |
41+
mkdir -p ~/.oci
42+
echo "${{ secrets.OCI_CONFIG }}" > ~/.oci/config
43+
echo "${{ secrets.OCI_KEY }}" > ~/.oci/key.pem
44+
chmod 600 ~/.oci/key.pem
45+
46+
- name: Deploy to OCI Container Instance
47+
run: |
48+
oci container-instances create \
49+
--compartment-id ${{ secrets.OCI_COMPARTMENT_ID }} \
50+
--availability-domain ${{ secrets.OCI_AVAILABILITY_DOMAIN }} \
51+
--shape ${{ secrets.OCI_SHAPE }} \
52+
--container-restart-policy ALWAYS \
53+
--containers '[{"image":"${{ secrets.OCI_REGISTRY }}/${{ secrets.OCI_NAMESPACE }}/adminhubapi:${{ github.sha }}","displayName":"adminhubapi"}]'

0 commit comments

Comments
 (0)