-
Notifications
You must be signed in to change notification settings - Fork 48
77 lines (68 loc) · 2.43 KB
/
ghcr-analysis.yml
File metadata and controls
77 lines (68 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: GHCR Mirror - Analysis
on:
workflow_dispatch:
inputs:
mode:
description: 'Which image to mirror'
required: true
type: choice
options:
- staging
- release
jobs:
mirror-staging:
name: Mirror staging to GHCR
if: inputs.mode == 'staging'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Mirror staging image to GHCR
run: |
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
docker pull codecharta/codecharta-analysis:staging
docker tag codecharta/codecharta-analysis:staging ghcr.io/${OWNER}/codecharta-analysis:staging
docker push ghcr.io/${OWNER}/codecharta-analysis:staging
mirror-release:
name: Mirror release to GHCR
if: inputs.mode == 'release'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Mirror release image to GHCR
run: |
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
VERSION=$(git tag --sort=-creatordate | grep '^ana-' | head -1 | sed 's/^ana-//')
echo "Mirroring version: ${VERSION}"
docker pull codecharta/codecharta-analysis:latest
docker tag codecharta/codecharta-analysis:latest ghcr.io/${OWNER}/codecharta-analysis:latest
docker tag codecharta/codecharta-analysis:latest ghcr.io/${OWNER}/codecharta-analysis:${VERSION}
docker push ghcr.io/${OWNER}/codecharta-analysis:latest
docker push ghcr.io/${OWNER}/codecharta-analysis:${VERSION}