set action to build for amd/arm #3
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: Deploy to Oracle Cloud K8s | |
on: | |
push: | |
branches: [ main ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Extract metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=sha,format=long | |
type=ref,event=branch | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Install OCI CLI | |
run: | | |
curl -L -O https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh | |
chmod +x install.sh | |
./install.sh --accept-all-defaults | |
echo "/home/runner/bin" >> $GITHUB_PATH | |
- name: Configure OCI CLI | |
run: | | |
mkdir -p ~/.oci | |
echo "${{ secrets.OCI_CONFIG }}" > ~/.oci/config | |
echo "${{ secrets.OCI_PRIVATE_KEY }}" > ~/.oci/key.pem | |
chmod 600 ~/.oci/config ~/.oci/key.pem | |
- name: Install kubectl | |
uses: azure/setup-kubectl@v3 | |
- name: Configure kubectl | |
run: | | |
mkdir -p ~/.kube | |
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config | |
chmod 600 ~/.kube/config | |
- name: Update deployment image | |
run: | | |
kubectl set image deployment/friends-connect friends-connect=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.meta.outputs.digest }} | |
kubectl rollout status deployment/friends-connect |