Skip to content

[Integration][PagerDuty] Show also secondaries on call on PagerDuty S… #705

[Integration][PagerDuty] Show also secondaries on call on PagerDuty S…

[Integration][PagerDuty] Show also secondaries on call on PagerDuty S… #705

name: Release integrations
on:
push:
branches:
- main
workflow_dispatch:
jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.prepare-matrix.outputs.INTEGRATIONS_MATRIX }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_MACHINE_USER }}
password: ${{ secrets.DOCKER_MACHINE_TOKEN }}
- name: Prepare matrix
id: prepare-matrix
run: |
integrations_to_release=()
# Get the list of integrations
files=$(find integrations/*/.port -name "spec.yaml")
for file in $files; do
folder=$(dirname "$file")
type=$(grep -E '^name = ".*"' "$folder/../pyproject.toml" | cut -d'"' -f2)
# Get the version from pyproject.toml
version=$(grep -E '^version = ".*"' "$folder/../pyproject.toml" | cut -d'"' -f2)
# Check if the version exists in the ghcr.io registry
rc=0
docker manifest inspect ghcr.io/port-labs/port-ocean-$type:$version > /dev/null 2>&1 || rc=$?
if [ $rc -eq 0 ]; then
echo "Image already exists in $repository: port-ocean-$type:$version"
else
integrations_to_release+=($file)
fi
done
echo $(echo ${integrations_to_release[@]} | jq -R -c 'split(" ")')
echo "INTEGRATIONS_MATRIX=$(echo ${integrations_to_release[@]} | jq -R -c 'split(" ")')" >> $GITHUB_OUTPUT
release-integration:
runs-on: ubuntu-latest
if: needs.prepare-matrix.outputs.matrix != '[]'
outputs:
is_dev_version: ${{ steps.prepare_tags.outputs.is_dev_version }}
permissions:
packages: write
contents: read
needs: [prepare-matrix]
strategy:
matrix:
integration: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_MACHINE_USER }}
password: ${{ secrets.DOCKER_MACHINE_TOKEN }}
- name: Prepare Docker images tags
id: prepare_tags
run: |
current_integration_spec=${{ matrix.integration }}
folder=$(dirname "$current_integration_spec")
context_dir=$(dirname "$folder")
echo "context_dir=$context_dir" >> $GITHUB_OUTPUT
version=$(grep -E '^version = ".*"' "$folder/../pyproject.toml" | cut -d'"' -f2)
type=$(grep -E '^name = ".*"' "$folder/../pyproject.toml" | cut -d'"' -f2)
echo "version=$version" >> $GITHUB_OUTPUT
dockerfile_path=integrations/_infra/Dockerfile
if test -e $folder/../Dockerfile; then
dockerfile_path=$folder/../Dockerfile
fi
echo "dockerfile_path=$dockerfile_path" >> $GITHUB_OUTPUT
# Check if the 'version' variable contains any character other than digits and "."
if [[ ! "$version" =~ ^[0-9.]+$ ]]; then
# If 'version' contains non-numeric and non-dot characters, skip building 'latest' tag
tags="ghcr.io/port-labs/port-ocean-$type:$version"
echo "tags=$tags" >> $GITHUB_OUTPUT
echo "is_dev_version=true" >> $GITHUB_OUTPUT
echo "Version contains non-numeric characters. Building without 'latest' tag."
else
# If 'version' contains only digits and dots, build with both 'latest' and version tags
tags="ghcr.io/port-labs/port-ocean-$type:$version,ghcr.io/port-labs/port-ocean-$type:latest"
echo "tags=$tags" >> $GITHUB_OUTPUT
echo "is_dev_version=false" >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ steps.prepare_tags.outputs.dockerfile_path }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.prepare_tags.outputs.tags }}
build-args: |
BUILD_CONTEXT=${{ steps.prepare_tags.outputs.context_dir }}
INTEGRATION_VERSION=${{ steps.prepare_tags.outputs.version }}
upload-specs:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: release-integration
if: needs.release-integration.outputs.is_dev_version == 'false'
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Configure AWS Credentials 🔒
id: 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 }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload specifications to s3
run: |
# Temporary file to store the concatenated YAML content
all_integrations_temp_file="all_integrations_temp_file.yaml"
# Temporary file to store each integration YAML content
specific_integration_temp_file="specific_integration_temp_file.yaml"
# Output file name
output_file="index.json"
# AWS S3 bucket details
aws_s3_bucket="ocean-registry"
# Find all ocean-spec.yaml files under the specified directory
find integrations/*/.port -type f -name "spec.yaml" > file_list.txt
while IFS= read -r file; do
integration_dir=$(dirname "$file")
# Extract the type for pyproject.toml
type=$(grep -E '^name = ".*"' "$integration_dir/../pyproject.toml" | cut -d'"' -f2)
# Extract the version from pyproject.toml
version=$(grep -E '^version = ".*"' "$integration_dir/../pyproject.toml" | cut -d'"' -f2)
# Store the integration's yaml file content into a temporary file
integration_dest="$(echo $integration_dir | awk -F'/' '{print $2}').json"
sed 's/^/ /' "$file" > "$specific_integration_temp_file"
echo " type: $type" >> "$specific_integration_temp_file"
echo " version: $version" >> "$specific_integration_temp_file"
yq -o=json . < "$specific_integration_temp_file" > "$integration_dest"
aws s3 cp "$integration_dest" "s3://$aws_s3_bucket/$integration_dest"
# Concatenate the YAML files into a temporary file
echo "- " >> "$all_integrations_temp_file"
cat "$specific_integration_temp_file" >> "$all_integrations_temp_file"
done < file_list.txt
yq -o=json . < "$all_integrations_temp_file" > "$output_file"
aws s3 cp "$output_file" "s3://$aws_s3_bucket/$output_file"