How to update GitHub actions workflow file using another workflow?
tldr; pass a custom created token with workflow permissions to actions/checkout using repository secrets

I am self-driven, practical, and hardworking. Quite often likes to exercise entrepreneurial thoughts and talk about creating solutions. I am driven by creating an impact and desire to help newcomers coming after me on the same path. One of my most notable traits is my determination and grit. I am a generalist always excited to learn something new. A kinesthetic learner, biased toward Linux, with contagious energy.
If you are facing a permission error as shown in the cover photo, you are on the right place. So, let say you have one workflow file with name my_workflow.yml and you want to update it using another workflow file, say my_workflow_updater.yml .
Create a token with permissions to update workflow
Create a token (classic) with workflow option checked in scope. Fill in Note and Expiration as desired.
Click Generate token button.
Copy new generated token starting with ghp_.... . It's important to do it at this step because it will not appear again and you will have to generate a new one.
Store Copied token as Secret in the repository
Go to the repository where you are creating that workflow. Click on Settings tab. In the Security section in the left column, expand Secrets and variables. Click on Actions. Click on New repository secret button under Repository secrets section in the main section.
Fill in an appropriate Name, and put that copied token into Secret. Click on Add secret. Name, here, is critical because this what you will use to access this secret or token.
Pass this custom token to that workflow file during checkout
Update my_workflow_updater.yml like following
jobs:
update-date:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.UPDATE_ACTION }}
...
token is what I want you to look at in the above section. Notice that UPDATE_ACTION is the name we used when creating a new secret for the repository in the last step.
That's it. Have fun.







