Skip to content

Refactor OCI deployment workflow for improved efficiency #5

Refactor OCI deployment workflow for improved efficiency

Refactor OCI deployment workflow for improved efficiency #5

Workflow file for this run

name: Deploy to OCI Container Instances
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'
- name: Build and publish
run: |
dotnet restore
dotnet build --configuration Release
dotnet publish --configuration Release --output ./publish
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Oracle Cloud Infrastructure Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.OCI_REGISTRY }}
username: ${{ secrets.OCI_USERNAME }}
password: ${{ secrets.OCI_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.OCI_REGISTRY }}/${{ secrets.OCI_REPOSITORY }}:${{ github.sha }}
- name: Deploy to Container Instances
uses: oracle-actions/run-oci-cli-command@v1
with:
command: container-instances create-container-instance
args: |
--compartment-id ${{ secrets.OCI_COMPARTMENT_ID }}
--availability-domain ${{ secrets.OCI_AVAILABILITY_DOMAIN }}
--shape ${{ secrets.OCI_SHAPE }}
--display-name my-app
--container-config '[{"image":"${{ secrets.OCI_REGISTRY }}/${{ secrets.OCI_REPOSITORY }}:${{ github.sha }}"}]'