I have been using this documentation called Checkout Actions to build a Continuous Integration workflow using GitHub Actions. In general, it works when dealing with public and private repositories.
This is the template:
- name: Checkout my_organization/my_private_repository
uses: actions/checkout@v3
with:
repository: my_organization/my_private_repository
ref: main
path: my_private_repository
token: ${{ secrets.MY_PRIVATE_REPOSITORY_SECRET_ACTIONS }}
- name: lein install my_private_repository
run:
cd my_private_repository && git checkout 60cfa20 && lein install && cd ..
I need almost the snippet above. The only thing missing is that I would like to check out a specific commit on main
branch. The commit ID is 60cfa20
.
I tried inserting as code to-be run after the cd
to the repository. Unfortunately, it did not work. See below:
- name: Checkout my_organization/my_private_repository
uses: actions/checkout@v3
with:
repository: my_organization/my_private_repository
ref: main
path: my_private_repository
token: ${{ secrets.MY_PRIVATE_REPOSITORY_SECRET_ACTIONS }}
- name: lein install my_private_repository
run:
cd my_private_repository && git checkout 60cfa20 && lein install && cd ..
I also tried inserting the commit ID on ref:
- name: Checkout my_organization/my_private_repository
uses: actions/checkout@v3
with:
repository: my_organization/my_private_repository
ref: main/60cfa20
path: my_private_repository
token: ${{ secrets. MY_REPOSITORY_SECRET_ACTIONS }}
- name: lein install my_private_repository
run:
cd my_private_repository && lein install && cd ..
But, it did not work out.
How to fix this? How to check out a particular commit ID?
In addition of fetch depth:0
, I would recommend a combination of git clean
+ git restore
(instead of git checkout
, which is obsolete since Git 2.23)
- name: lein install my_private_repository
run: |
cd my_private_repository
git clean -xdf
git restore -SW 60cfa20
lein install
cd ..