Merge remote-tracking branch 'origin/main' #20
This file contains hidden or 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: 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: Set up OCI CLI | |
run: | | |
curl -L -O https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh | |
bash install.sh --accept-all-defaults | |
mkdir -p ~/.oci | |
echo "${{ secrets.OCI_CONFIG }}" > ~/.oci/config | |
echo "${{ secrets.OCI_KEY }}" > ~/.oci/key.pem | |
chmod 600 ~/.oci/key.pem | |
chmod 600 ~/.oci/config | |
echo "export PATH=$PATH:$HOME/bin" >> $GITHUB_ENV | |
source $HOME/.bashrc | |
- name: Deploy to Container Instances | |
run: | | |
# Use the full path to the OCI CLI executable | |
/home/runner/bin/oci container-instances container-instance create \ | |
--compartment-id ${{ secrets.OCI_COMPARTMENT_ID }} \ | |
--availability-domain ${{ secrets.OCI_AVAILABILITY_DOMAIN }} \ | |
--shape ${{ secrets.OCI_SHAPE }} \ | |
--display-name my-app \ | |
--containers '[{"image":"${{ secrets.OCI_REGISTRY }}/${{ secrets.OCI_REPOSITORY }}:${{ github.sha }}"}]' \ | |
--shape-config '{"ocpus": 1, "memory-in-gbs": 2}' \ | |
--vnics '[{"subnet-id": "${{ secrets.OCI_SUBNET_ID }}"}]' |