-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (50 loc) · 1.72 KB
/
push-ghcr-image.yml
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
name: Build and push latest GHCR Docker image
on:
workflow_call:
secrets:
DOCKER_GHCR:
description: Docker GHCR token
required: true
inputs:
git_tag_name:
required: true
type: string
workflow_dispatch:
inputs:
git_tag_name:
description: Git version tag (eg. v0.9.0)
required: true
jobs:
push-image:
name: Push latest image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.DOCKER_GHCR }}
- name: Fetch all tags
run: git fetch --tags
- name: Build Docker image
run: docker build -t tinted-builder-rust .
- name: Tag Docker image
run: |
docker tag tinted-builder-rust ghcr.io/tinted-theming/tinted-builder-rust:${{ inputs.git_tag_name }}
docker tag tinted-builder-rust ghcr.io/tinted-theming/tinted-builder-rust:latest
- name: Log in to GitHub Container Registry
run: echo ${{ secrets.DOCKER_GHCR }} | docker login ghcr.io -u tinted-theming-bot --password-stdin
- name: Push Docker image
run: |
docker push ghcr.io/tinted-theming/tinted-builder-rust:${{ inputs.git_tag_name }}
docker push ghcr.io/tinted-theming/tinted-builder-rust:latest
- name: Remove existing 'latest' tag
run: |
if git rev-parse latest >/dev/null 2>&1; then
git tag -d latest
git push origin :refs/tags/latest
fi
- name: Add 'latest' tag to LATEST_TAG commit
run: |
git_tag_commit_hash=$(git rev-list -n 1 ${{ inputs.git_tag_name }})
git tag latest ${git_tag_commit_hash}
git push origin latest