Skip to content

[Legacy] Publish Connector Image #15

[Legacy] Publish Connector Image

[Legacy] Publish Connector Image #15

name: "[Legacy] Publish Connector Image"
on:
workflow_dispatch:
inputs:
repo:
description: "Repo to check out code from. Defaults to the main airbyte repo. Set this when building connectors from forked repos."
required: false
default: "airbytehq/airbyte"
gitref:
description: "The git ref to check out from the specified repository."
required: false
default: master
connector:
description: "Airbyte Connector"
required: true
comment-id:
description: "The comment-id of the slash command. Used to update the comment with the status."
required: false
parallel:
description: "Switching this to true will spin up 5 build agents instead of 1 and allow multi connector publishes to run in parallel"
required: true
default: "false"
run-tests:
description: "Should run tests when publishing"
required: true
default: "true"
pre-release:
description: "Should publish a pre-release version"
required: true
default: "false"
jobs:
## Gradle Build
# In case of self-hosted EC2 errors, remove this block.
start-publish-image-runner-0:
name: Start Build EC2 Runner 0
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-1:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 1
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-2:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 2
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-3:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 3
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-4:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 4
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
preprocess-matrix:
needs: start-publish-image-runner-0
runs-on: ${{ needs.start-publish-image-runner-0.outputs.label }}
outputs:
connectorjson: ${{ steps.preprocess.outputs.connectorjson }}
steps:
# given a string input of a single connector or comma separated list of connectors e.g. connector1, connector2
# this step builds an array, by removing whitespace, add in quotation marks around connectors and braces [ ] at the start and end
# finally, it sets it as output from this job so we can use this array of connectors as our matrix strategy for publishing
- id: preprocess
run: |
start="[\""
replace="\",\""
end="\"]"
stripped_connector="$(echo "${{ github.event.inputs.connector }}" | tr -d ' ')"
middle=${stripped_connector//,/$replace}
full="$start$middle$end"
echo "connectorjson=$full" >> $GITHUB_OUTPUT
write-initial-output-to-comment:
name: Set up git comment
if: github.event.inputs.comment-id
needs: start-publish-image-runner-0
runs-on: ${{ needs.start-publish-image-runner-0.outputs.label }}
steps:
- name: Print start message
if: github.event.inputs.comment-id && success()
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
> :clock2: Publishing the following connectors:<br>${{ github.event.inputs.connector }}<br>https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- name: Create table header
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
<br>
| Connector | Version | Did it publish? |
- name: Create table separator
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
| --- | --- | --- |
publish-image:
timeout-minutes: 240
needs:
- start-publish-image-runner-0
- preprocess-matrix
- write-initial-output-to-comment
strategy:
max-parallel: 5
fail-fast: false
matrix:
connector: ${{ fromJSON(needs.preprocess-matrix.outputs.connectorjson) }}
runs-on: runner-pool-${{ github.run_id }}
steps:
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SPEC_CACHE_SERVICE_ACCOUNT_KEY }}
export_default_credentials: true
- name: Search for valid connector name format
id: regex
uses: AsasInnab/regex-action@v1
with:
regex_pattern: "^(connectors|bases)/[a-zA-Z0-9-_]+$"
regex_flags: "i" # required to be set for this plugin
search_string: ${{ matrix.connector }}
- name: Validate input workflow format
if: steps.regex.outputs.first_match != matrix.connector
run: echo "The connector provided has an invalid format!" && exit 1
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
token: ${{ secrets.GH_PAT_MAINTENANCE_OSS }}
- name: Install Java
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install Pyenv
run: |
python3 -m pip install --quiet virtualenv==16.7.9 --user
rm -r venv || echo "no pre-existing venv"
python3 -m virtualenv venv
source venv/bin/activate
- name: Install CI scripts
# all CI python packages have the prefix "ci_"
run: |
source venv/bin/activate
pip install --quiet -e ./tools/ci_*
- name: Write Integration Test Credentials for ${{ matrix.connector }}
run: |
source venv/bin/activate
ci_credentials ${{ matrix.connector }} write-to-storage
# normalization also runs destination-specific tests, so fetch their creds also
if [ 'bases/base-normalization' = "${{ matrix.connector }}" ] || [ 'base-normalization' = "${{ matrix.connector }}" ]; then
ci_credentials destination-bigquery write-to-storage
ci_credentials destination-postgres write-to-storage
ci_credentials destination-snowflake write-to-storage
fi
env:
GCP_GSM_CREDENTIALS: ${{ secrets.GCP_GSM_CREDENTIALS }}
- name: Set Name and Version Environment Vars
if: startsWith(matrix.connector, 'connectors')
run: |
source tools/lib/lib.sh
DOCKERFILE=airbyte-integrations/${{ matrix.connector }}/Dockerfile
echo "IMAGE_NAME=$(echo ${{ matrix.connector }} | cut -d"/" -f2)" >> $GITHUB_ENV
echo "IMAGE_VERSION=$(_get_docker_image_version ${DOCKERFILE} ${{ github.event.inputs.pre-release }})" >> $GITHUB_ENV
- name: Prepare Sentry
if: startsWith(matrix.connector, 'connectors')
uses: Wandalen/wretry.action@master
with:
attempt_limit: 3
attempt_delay: 5000 # in ms
command: curl -sL https://sentry.io/get-cli/ | bash || echo "sentry cli already installed"
- name: Run QA checks for ${{ matrix.connector }}
id: qa_checks
if: always()
run: |
source venv/bin/activate
run-qa-checks ${{ matrix.connector }}
- name: Publish ${{ matrix.connector }}
id: publish
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
# Oracle expects this variable to be set. Although usually present, this is not set by default on Github virtual runners.
TZ: UTC
uses: Wandalen/wretry.action@master
with:
command: |
echo "$SPEC_CACHE_SERVICE_ACCOUNT_KEY" > spec_cache_key_file.json && docker login -u ${DOCKER_HUB_USERNAME} -p ${DOCKER_HUB_PASSWORD}
./tools/integrations/manage.sh publish airbyte-integrations/${{ matrix.connector }} ${{ github.event.inputs.run-tests }} --publish_spec_to_cache ${{ github.event.inputs.pre-release == 'true' && '--pre_release' || '' }}
attempt_limit: 3
attempt_delay: 5000 in # ms
- name: Update Integration Test Credentials after test run for ${{ github.event.inputs.connector }}
if: always()
run: |
source venv/bin/activate
ci_credentials ${{ matrix.connector }} update-secrets
# normalization also runs destination-specific tests, so fetch their creds also
if [ 'bases/base-normalization' = "${{ matrix.connector }}" ] || [ 'base-normalization' = "${{ matrix.connector }}" ]; then
ci_credentials destination-bigquery update-secrets
ci_credentials destination-postgres update-secrets
ci_credentials destination-snowflake update-secrets
fi
env:
GCP_GSM_CREDENTIALS: ${{ secrets.GCP_GSM_CREDENTIALS }}
- name: Create Sentry Release
if: startsWith(matrix.connector, 'connectors') && success()
run: |
SENTRY_RELEASE_NAME="airbyte-${{ env.IMAGE_NAME }}@${{ env.IMAGE_VERSION }}"
sentry-cli releases set-commits "$SENTRY_RELEASE_NAME" --auto --ignore-missing &&
sentry-cli releases finalize "$SENTRY_RELEASE_NAME"
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_CONNECTOR_RELEASE_AUTH_TOKEN }}
SENTRY_ORG: airbytehq
SENTRY_PROJECT: connector-incident-management
- name: Process outcomes into emojis
if: ${{ always() && github.event.inputs.comment-id }}
run: |
if [[ ${{ steps.publish.outcome }} = "success" ]]; then
echo "PUBLISH_OUTCOME=:white_check_mark:" >> $GITHUB_ENV
else
echo "PUBLISH_OUTCOME=:x:" >> $GITHUB_ENV
fi
- name: Add connector outcome line to table
if: ${{ always() && github.event.inputs.comment-id }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
| ${{ matrix.connector }} | ${{ env.IMAGE_VERSION }} | ${{ env.PUBLISH_OUTCOME }} |
add-helpful-info-to-git-comment:
if: ${{ always() && github.event.inputs.comment-id }}
name: Add extra info to git comment
needs:
- start-publish-image-runner-0 # required to get output from the start-runner job
- publish-image # required to wait when the main job is done
runs-on: ubuntu-latest
steps:
- name: Add hint for manual seed definition update
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
<br>
if you have connectors that successfully published but failed definition generation, follow [step 4 here ▶️](https://docs.airbyte.com/connector-development/#publishing-a-connector)
# In case of self-hosted EC2 errors, remove this block.
stop-publish-image-runner-0:
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
name: Stop Build EC2 Runner
needs:
- start-publish-image-runner-0 # required to get output from the start-runner job
- preprocess-matrix
- publish-image # required to wait when the main job is done
- add-helpful-info-to-git-comment
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Checkout Airbyte
uses: actions/checkout@v3
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Stop EC2 runner
uses: airbytehq/ec2-github-runner@base64v1.1.0
with:
mode: stop
github-token: ${{ env.PAT }}
label: ${{ needs.start-publish-image-runner-0.outputs.label }}
ec2-instance-id: ${{ needs.start-publish-image-runner-0.outputs.ec2-instance-id }}
stop-publish-image-runner-multi:
if: ${{ always() && github.event.inputs.parallel == 'true' }}
name: Stop Build EC2 Runner
needs:
- start-publish-image-runner-0
- start-publish-image-runner-1
- start-publish-image-runner-2
- start-publish-image-runner-3
- start-publish-image-runner-4
- preprocess-matrix
- publish-image # required to wait when the main job is done
strategy:
fail-fast: false
matrix:
ec2-instance:
[
{
"label": "${{ needs.start-publish-image-runner-1.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-1.outputs.ec2-instance-id }}",
},
{
"label": "${{ needs.start-publish-image-runner-2.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-2.outputs.ec2-instance-id }}",
},
{
"label": "${{ needs.start-publish-image-runner-3.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-3.outputs.ec2-instance-id }}",
},
{
"label": "${{ needs.start-publish-image-runner-4.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-4.outputs.ec2-instance-id }}",
},
]
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Checkout Airbyte
uses: actions/checkout@v3
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Stop EC2 runner
uses: airbytehq/ec2-github-runner@base64v1.1.0
with:
mode: stop
github-token: ${{ env.PAT }}
label: ${{ matrix.ec2-instance.label }}
ec2-instance-id: ${{ matrix.ec2-instance.id }}