-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (70 loc) · 2.39 KB
/
docker.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
name: docker
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
packages: write
contents: read
jobs:
build-and-push:
name: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Determine tag name
id: determine_tag
shell: bash
run: |
if [[ -z "${GITHUB_BASE_REF}" ]]; then
# On master/stable branches.
tag=${GITHUB_REF#refs/heads/}
else
# On pull request branches.
tag=pr-$(git describe --always --abbrev=7)
fi
tag=${tag//\//-}
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Rebuild ghcr.io/oasisprotocol/testnet-faucet:${{ steps.determine_tag.outputs.tag }}"
uses: docker/build-push-action@v6
with:
file: deploy/Dockerfile
tags: ghcr.io/oasisprotocol/testnet-faucet:${{ steps.determine_tag.outputs.tag }}
pull: true
push: true
provenance: false
labels: |
org.opencontainers.image.authors=${{ github.actor }}
org.opencontainers.image.description=Testnet Faucet Docker image
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.organization=${{ github.repository_owner }}
org.opencontainers.image.created=${{ steps.determine_tag.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Prune old ghcr.io/oasisprotocol/testnet-faucet images
uses: vlaurin/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: oasisprotocol
container: testnet-faucet
keep-younger-than: 7 # days
keep-last: 2
prune-untagged: true
prune-tags-regexes: ^pr-