Skip to content

Commit

Permalink
revert most circleci changes since 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wdbaruni committed Jun 24, 2024
1 parent 233a852 commit 912e335
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 332 deletions.
12 changes: 0 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ parameters:
default: "build-vm-linux-amd64"
type: string

PUSH_BRANCH:
default: "main"
type: string

PUSH_TAG:
default: "v0.0.0"
type: string

full_name:
default: "bacalhau-project/bacalhau"
type: string

executors:
# Available resource classes - https://circleci.com/product/features/resource-classes/
linux-amd64:
Expand Down
158 changes: 0 additions & 158 deletions .circleci/push-to-upstream-fork.py

This file was deleted.

91 changes: 0 additions & 91 deletions .circleci/trigger_circleci.py

This file was deleted.

19 changes: 19 additions & 0 deletions .circleci/trigger_pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -xeuo pipefail
IFS=$'\n\t'

if [[ -z "${BRANCH}" ]]; then
TARGET="\"branch\": \"main\""
elif [[ "${BRANCH}" =~ "refs/tags" ]]; then
TAG=$(echo "${BRANCH}" | sed 's:refs/tags/::')
TARGET="\"tag\": \"${TAG}\""
else
TARGET="\"branch\": \"${BRANCH}\""
fi

curl --fail -X POST --header "Content-Type: application/json" --header "Circle-Token: ${CIRCLE_TOKEN}" -d "{
\"parameters\": {
\"GHA_Action\": \"trigger_pipeline\"
},
${TARGET}
}" https://circleci.com/api/v2/project/gh/bacalhau-project/bacalhau/pipeline
34 changes: 34 additions & 0 deletions .github/trigger-on-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Trigger on Label

on:
pull_request:
types: [labeled]

jobs:
trigger-workflows:
if: github.event.label.name == 'ok-to-test'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install yq
run: sudo snap install yq

- name: Check if labeler is authorized
id: check-authorization
run: |
LABELER=$(jq --raw-output .sender.login "$GITHUB_EVENT_PATH")
APPROVERS=$(yq e '.approvers[]' OWNERS)
if echo "$APPROVERS" | grep -Fxq "$LABELER"; then
echo "::set-output name=authorized::true"
else
echo "::set-output name=authorized::false"
fi
- name: Dispatch event
if: steps.check-authorization.outputs.authorized == 'true'
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: ok-to-test
49 changes: 10 additions & 39 deletions .github/workflows/circleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
types:
- completed
repository_dispatch:
types: [ok-to-test, ok-to-trigger-circleci]
types: [ok-to-test]

permissions:
contents: write
Expand All @@ -21,14 +21,12 @@ permissions:
jobs:
trigger-circle-ci:
if: |
github.event_name != 'pull_request' ||
(
!contains(github.event.pull_request.labels.*.name, 'do-not-merge') &&
!contains(github.event.pull_request.labels.*.name, 'wip')
)
!contains(github.event.pull_request.labels.*.name, 'do-not-merge') &&
!contains(github.event.pull_request.labels.*.name, 'wip')
runs-on: ubuntu-latest
name: Pull Request Triggered CircleCI
steps:
# For Debugging Below
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
Expand All @@ -46,41 +44,14 @@ jobs:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- uses: actions/checkout@v3
- if: ${{ github.event_name != 'pull_request' }}
run: echo "Not a pull request. Exiting."
- name: Set up ref
id: set-ref
- name: Trigger CircleCI
id: trigger-circle-ci
run: |
if [[ -n "${{ github.event.client_payload.ref }}" ]]; then
echo "Payload ref: ${{ github.event.client_payload.ref }}"
echo "REF=${{ github.event.client_payload.ref }}" >> $GITHUB_ENV
elif [[ -n "${{ github.event.pull_request.head.ref }}" ]]; then
echo "PR ref: ${{ github.event.pull_request.head.ref }}"
echo "REF=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
elif [[ -n "${{ github.sha }}" ]]; then
echo "REF: ${{ github.sha }}"
echo "REF=${{ github.sha }}" >> $GITHUB_ENV
else
echo "No SHA set. Exiting."
if [[ -z $CIRCLE_TOKEN ]]; then
echo "CIRCLE_TOKEN is not set. Exiting."
exit 1
fi
if [[ -n "${{ github.event.client_payload.full_name }}" ]]; then
echo "FULL_NAME=${{ github.event.client_payload.full_name }}" >> $GITHUB_ENV
else
echo "FULL_NAME=${{ github.repository }}" >> $GITHUB_ENV
fi
- uses: hmarr/debug-action@v3

- name: "Trigger CircleCI"
id: trigger-circle-ci
run: |
python -m pip install poetry
poetry install
source $(poetry env info --path)/bin/activate
python ./.circleci/trigger_circleci.py
./.circleci/trigger_pipeline.sh
env:
CIRCLE_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
REF: ${{ env.REF }}
FULL_NAME: ${{ github.repository }}
BRANCH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.event.ref }}
Loading

0 comments on commit 912e335

Please sign in to comment.