Skip to content

WIP

WIP #1077

Workflow file for this run

name: Gateway Commons
on: push
env:
GATEWAY_REPOSITORY_NAME: gateway
GATEWAY_SCHEDULER_REPOSITORY_NAME: gateway-scheduler
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-deployment-matrix.outputs.matrix }}
matrixLength: ${{ steps.set-deployment-matrix.outputs.matrixLength }}
steps:
- name: Set Deployment Matrix
id: set-deployment-matrix
run: |
branchName=$(echo '${{ github.ref }}' | sed 's,refs/heads/,,g')
matrixSource=$(cat << EOF
[
{
"identifier": "gateway-commons-staging",
"branch": "develop",
"friendly_image_tag": "beta",
"image_tag": "stag-${{ github.sha }}"
},
{
"identifier": "gateway-commons",
"branch": "master",
"friendly_image_tag": "latest",
"image_tag": "prod-${{ github.sha }}"
}
]
EOF
)
matrix=$(echo $matrixSource | jq --arg branchName "$branchName" 'map(. | select((.branch==$branchName)) )')
echo "matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
echo "matrixLength=$(echo $matrix | jq length)" >> $GITHUB_OUTPUT
build-packages:
name: Build Packages
runs-on: ubuntu-latest
if: needs.build.outputs.matrixLength > 0
strategy:
matrix: ${{fromJson(needs.build.outputs.matrix)}}
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-skip-session-tagging: true
role-duration-seconds: 3600
aws-region: ap-southeast-1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to ECR
uses: docker/login-action@v3
with:
registry: ${{ secrets.ECR_REGISTRY }}
- name: Build and push Gateway Scheduler
uses: docker/build-push-action@v6
with:
context: components/opensips_scheduler
push: true
platforms: linux/amd64
cache-from: type=gha,scope=${{ matrix.identifier }}-gateway-scheduler
cache-to: type=gha,mode=max,scope=${{ matrix.identifier }}-gateway-scheduler
tags: |
${{ secrets.ECR_REGISTRY }}/${{ env.GATEWAY_SCHEDULER_REPOSITORY_NAME }}:${{ matrix.image_tag }}
${{ secrets.GHCR_REGISTRY }}/${{ env.GATEWAY_SCHEDULER_REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-amd64
${{ secrets.GHCR_REGISTRY }}/${{ env.GATEWAY_SCHEDULER_REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}
- name: Build and push Gateway
uses: docker/build-push-action@v6
with:
context: components/gateway
target: bootstrap
push: true
platforms: linux/amd64
cache-from: type=gha,scope=${{ matrix.identifier }}-gateway
cache-to: type=gha,mode=max,scope=${{ matrix.identifier }}-gateway
tags: |
${{ secrets.GHCR_REGISTRY }}/${{ env.GATEWAY_REPOSITORY_NAME }}:bootstrap-amd64
${{ secrets.GHCR_REGISTRY }}/${{ env.GATEWAY_REPOSITORY_NAME }}:bootstrap