Tricks For Packup
1/21/2025
A. GitHub Actions
A.01 - Clone Private Repo
1. Create a Personal Access Token (PAT):
- Go to your GitHub settings (https://github.com/settings/tokens).
2. Add the PAT as a GitHub Secret:
- In your repository, go to "Settings" -> "Secrets" -> "Actions."
- Give it a name (e.g.,
GITHUB_TOKEN).
3. Use the PAT in your GitHub Actions workflow:
Method A: Using actions/checkout with a token:
yaml
jobs:
clone:
runs-on: ubuntu-latest
steps:
- name: Checkout main repository
uses: actions/checkout@v3
- name: Checkout private repository
uses: actions/checkout@v3
with:
repository: owner/repo # Replace with the owner and repository name
token: ${{ secrets.GITHUB_TOKEN }} # Use the secret you createdMethod B: Using git clone directly:
yaml
jobs:
clone:
runs-on: ubuntu-latest
steps:
- name: Checkout main repository
uses: actions/checkout@v3
- name: Clone private repository
run: |
git clone https://${{ secrets.GITHUB_TOKEN }}@github.com/owner/repo.git private-repoA.02 - Generate Docker Image Tags
- Each building have a
latesttag and SHA tag. - Only git tag triggered building have semver tags.
yaml
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: yourimage
tags: |
type=raw,value=latest
type=sha,format=long
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/') }}B. Docker Build
B.01 - pip install cache
docker
RUN --mount=type=cache,target=/root/.cache/pip pip install your_packageThis command will mount a Docker-managed cache storage to the default pip cached folder