File tree Expand file tree Collapse file tree 5 files changed +100
-0
lines changed
Expand file tree Collapse file tree 5 files changed +100
-0
lines changed Original file line number Diff line number Diff line change 1+ .dockerignore
2+ .github
3+ .README.md
Original file line number Diff line number Diff line change 1+ name : Delete Old Docker Image
2+
3+ on :
4+ workflow_dispatch :
5+
6+ jobs :
7+
8+ cleanup-redis :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+
13+ - name : Cleanup Docker images from GHCR
14+ uses : dataaxiom/ghcr-cleanup-action@v1
15+ with :
16+ token : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
17+ owner : multi-repo
18+ repository : redis
19+ keep-n-tagged : 1
20+ package : redis/redis
21+ dry-run : false
Original file line number Diff line number Diff line change 1+ name : Build Docker Images
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+
10+ ghcr-build-redis :
11+ runs-on : ubuntu-latest
12+ container :
13+ image : gcr.io/kaniko-project/executor:v1.23.0-debug
14+ options : --entrypoint /bin/sh
15+ permissions :
16+ packages : write
17+
18+
19+ steps :
20+
21+
22+ - name : Set branch name as environment variable
23+ run : echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
24+
25+ - name : Set up Docker config for Kaniko
26+ run : |
27+ cat <<EOF > /kaniko/.docker/config.json
28+ {
29+ "auths": {
30+ "ghcr.io": {
31+ "auth": "$(echo -n "$GIT_USERNAME:$GIT_PASSWORD" | base64 -w0)"
32+ }
33+ }
34+ }
35+ EOF
36+ env :
37+ GIT_USERNAME : ${{ github.actor }}
38+ GIT_PASSWORD : ${{ secrets.GITHUB_TOKEN }}
39+
40+
41+ - name : Build and push redis
42+ run : |
43+ /kaniko/executor --dockerfile="Dockerfile" \
44+ --context="${{ github.repositoryUrl }}#${{ github.ref_name }}#${{ github.sha }}" \
45+ --destination="$GH_REGISTRY/$IMAGE_NAME:${GITHUB_REF_NAME}" \
46+
47+ env :
48+ GH_REGISTRY : " ghcr.io"
49+ IMAGE_NAME : " ${{ github.repository }}/redis"
50+
51+
52+ delete-old-images :
53+ runs-on : ubuntu-latest
54+
55+ steps :
56+ - name : Trigger Delete Old Image Workflow
57+ run : |
58+ curl -X POST \
59+ -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
60+ -H "Accept: application/vnd.github.v3+json" \
61+ "https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ env.ACTION_NAME }}/dispatches" \
62+ -d '{"ref": "main"}'
63+ env :
64+ ACTION_NAME : delete-old-image.yml
65+
66+
67+ deploy :
68+ needs : [delete-old-images, ghcr-build-redis]
69+ runs-on : ubuntu-latest
70+ steps :
71+ - name : Deploy to environment
72+ run : |
73+ echo "Deploying application"
Original file line number Diff line number Diff line change 1+ FROM redis:8.0-M03-bookworm
2+ CMD [ "redis-server" ]
Original file line number Diff line number Diff line change 1+ ### Redis for backend
You can’t perform that action at this time.
0 commit comments