Push container images to OCI (#336) #192
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: Build images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| env: | |
| OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }} | |
| OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }} | |
| OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }} | |
| OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }} | |
| OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }} | |
| jobs: | |
| build-dbmigrator-image: | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-2 | |
| - name: Login to AWS ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Login to OCI Registry | |
| id: login-ocir | |
| uses: oracle-actions/[email protected] | |
| with: | |
| auth_token: ${{ secrets.OCI_AUTH_TOKEN }} | |
| - name: Get gitjobs-dbmigrator OCIR repository | |
| id: get-ocir-repository-dbmigrator | |
| uses: oracle-actions/[email protected] | |
| with: | |
| name: gitjobs/dbmigrator | |
| compartment: ${{ secrets.OCI_COMPARTMENT_OCID }} | |
| - name: Build and push gitjobs-dbmigrator image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| OCIR_REGISTRY: ${{ steps.login-ocir.outputs.ocir_endpoint }} | |
| OCIR_REPOSITORY: ${{ steps.get-ocir-repository-dbmigrator.outputs.repo_path }} | |
| run: | | |
| docker build \ | |
| -f database/migrations/Dockerfile \ | |
| -t $ECR_REGISTRY/gitjobs/dbmigrator:$GITHUB_SHA \ | |
| -t $OCIR_REPOSITORY:$GITHUB_SHA \ | |
| . | |
| docker push $ECR_REGISTRY/gitjobs/dbmigrator:$GITHUB_SHA | |
| docker push $OCIR_REPOSITORY:$GITHUB_SHA | |
| build-server-image: | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-2 | |
| - name: Login to AWS ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Login to OCI Registry | |
| id: login-ocir | |
| uses: oracle-actions/[email protected] | |
| with: | |
| auth_token: ${{ secrets.OCI_AUTH_TOKEN }} | |
| - name: Get gitjobs-server OCIR repository | |
| id: get-ocir-repository-server | |
| uses: oracle-actions/[email protected] | |
| with: | |
| name: gitjobs/server | |
| compartment: ${{ secrets.OCI_COMPARTMENT_OCID }} | |
| - name: Build and push gitjobs-server image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| OCIR_REGISTRY: ${{ steps.login-ocir.outputs.ocir_endpoint }} | |
| OCIR_REPOSITORY: ${{ steps.get-ocir-repository-server.outputs.repo_path }} | |
| run: | | |
| docker build \ | |
| -f gitjobs-server/Dockerfile \ | |
| -t $ECR_REGISTRY/gitjobs/server:$GITHUB_SHA \ | |
| -t $OCIR_REPOSITORY:$GITHUB_SHA \ | |
| . | |
| docker push $ECR_REGISTRY/gitjobs/server:$GITHUB_SHA | |
| docker push $OCIR_REPOSITORY:$GITHUB_SHA | |
| build-syncer-image: | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-2 | |
| - name: Login to AWS ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Login to OCI Registry | |
| id: login-ocir | |
| uses: oracle-actions/[email protected] | |
| with: | |
| auth_token: ${{ secrets.OCI_AUTH_TOKEN }} | |
| - name: Get gitjobs-syncer OCIR repository | |
| id: get-ocir-repository-syncer | |
| uses: oracle-actions/[email protected] | |
| with: | |
| name: gitjobs/syncer | |
| compartment: ${{ secrets.OCI_COMPARTMENT_OCID }} | |
| - name: Build and push gitjobs-syncer image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| OCIR_REGISTRY: ${{ steps.login-ocir.outputs.ocir_endpoint }} | |
| OCIR_REPOSITORY: ${{ steps.get-ocir-repository-syncer.outputs.repo_path }} | |
| run: | | |
| docker build \ | |
| -f gitjobs-syncer/Dockerfile \ | |
| -t $ECR_REGISTRY/gitjobs/syncer:$GITHUB_SHA \ | |
| -t $OCIR_REPOSITORY:$GITHUB_SHA \ | |
| . | |
| docker push $ECR_REGISTRY/gitjobs/syncer:$GITHUB_SHA | |
| docker push $OCIR_REPOSITORY:$GITHUB_SHA |