forked from Authentura/codectrl
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (70 loc) · 2.68 KB
/
update-server-container.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Auto-update Server container
on:
push:
branches: [main]
jobs:
build-container:
if: github.repository_owner == 'STBoyden'
name: Build server container
runs-on: ubuntu-latest
steps:
- run: echo "DATE=$(date +%d%m%Y_%H%M%S)" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: STBoyden/codectrl-protobuf-specifications
path: crates/protobuf-bindings/protos
- name: Fetch cache if already exists
continue-on-error: true
uses: actions/cache@v3
id: has-cache
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: server-${{ hashFiles('**/Cargo.lock') }}
- if: steps.has-cache.outputs.cache-hit != 'true'
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- if: steps.has-cache.outputs.cache-hit != 'true'
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- if: steps.has-cache.outputs.cache-hit != 'true'
name: Build
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/stboyden/codectrl:latest
ghcr.io/stboyden/codectrl:${{ github.sha }}
ghcr.io/stboyden/codectrl:${{ env.DATE }}
- if: steps.has-cache.outputs.cache-hit != 'true'
name: Push
run: |
set -x
docker push ghcr.io/stboyden/codectrl:latest
docker push ghcr.io/stboyden/codectrl:${{ github.sha }}
docker push ghcr.io/stboyden/codectrl:${{ env.DATE }}
set +x
echo "Pushed!"
echo "Pushed the following tags for the `codectrl` container" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- \`${{ github.sha }}\` -- The commit that used for the update of the container" >> $GITHUB_STEP_SUMMARY
echo "- \`${{ env.DATE }}\` -- The date and time on which the update for the container was ran" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The \`latest\` tag has been updated." >> $GITHUB_STEP_SUMMARY
- if: steps.has-cache.outputs.cache-hit == 'true'
name: Generate "no need" step summary
run: |
echo "No need to update `codectrl` container" >> $GITHUB_STEP_SUMMARY