Closed SegunRova closed 6 months ago
Hi @SegunRova, I just gave it a try and it worked as expected. Please check if you are following the same steps as I did:
.github/workflows/main.yml
:on: push
jobs:
trigger-codemagic-build:
runs-on: ubuntu-latest
steps:
- name: Trigger Codemagic build
uses: codemagic-ci-cd/trigger-codemagic-workflow-action@v2.0.0
with:
app-id: <MY-APPLICATION-ID>
workflow-id: <MY-WORKFLOW-ID>
token: ${{ secrets.CODEMAGIC_API_TOKEN }}
app-id
: Can be found in the tab URL (https://codemagic.io/app/MY_APP_ID/build/MY_BUILD_ID), workflow-id
: If working with codemagic.yaml, then it can be found in YAML:
workflows:
ios-workflow: => THIS IS WORKFLOW_ID
name: ios_workflow
instance_type: mac_mini_m2
If working with the workflow editor, it is in the tab url (https://codemagic.io/app/APP_ID/workflow/WORKFLOW_ID/settings)
and token
: Can be found in Teams > Personal Account > Integrations > Codemagic API
Hi @icarusdust , thank you for your response. yes I'm following the steps excepts that the file is not named main.yml, below is what my configuration file looks like
name: Integration test
# This workflow is triggered on pushes to the repository.
on:
repository_dispatch:
types: [go-integration-test, java-integration-test]
jobs:
services_job:
name: integration-test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: check out to repository
uses: actions/checkout@v3
with:
repository: roava/app
token: ${{ secrets.PAT }}
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.9'
channel: 'stable'
- name: Trigger Codemagic build
uses: codemagic-ci-cd/trigger-codemagic-workflow-action@v2.0.0
with:
app-id: <MY-APPLICATION-ID>
workflow-id: ${{ github.event.client_payload.name }} # this resolves to the name of the workflow i already created in codemagine i.e ms.test
branch: 'develop'
token: ${{ secrets.CODEMAGIC_API_TOKEN }}
The problem here is about what workflow-id
is resolved to. When applying a different workflow name than the actual one, you can reproduce more or less the same error regarding non-existing workflow. So,${{ github.event.client_payload.name }}
is resolved to an incorrect workflow name. Try it with the actual name, it should work.
Hi @icarusdust , I updated the pipeline to include the actual name but stll got the same error. it keep adding fromfile to the name
@SegunRova, it is not adding it to the workflow name, it refers to codemagic.yaml
where the build configs are from, you can ignore it.
So, the error is reproducible only when the given workflow name is incorrect.
Thank you sir, could it be that the API token is wrong, maybe the user which API token is been used does not have access to that workflow?
If the token is incorrect, you will receive Error: Request failed with status code 401: FORBIDDEN
, it won't proceed with the trigger.
Thank you @icarusdust , I found out the issue. The API triggers workflows created from a codemagic.yaml file, if does not trigger a workflow created from the workflow editor. Thank you for your time.
I'm using the action to trigger codemagic on repository dispatch.
However, when the action is triggered it does not use the existiong workflow created above, it tries to create a new one with a suffix file in the name, this makes codemagic to fail with error
workflow not found
.Please what I'm i doing wrong.