forked from compdemocracy/polis
-
-
Notifications
You must be signed in to change notification settings - Fork 4
61 lines (52 loc) · 2.01 KB
/
release-docker-images.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
# Changes to workflow name require changes to badge URL in README.md
name: Docker image builds
on:
push:
branches:
- edge-civictechto
jobs:
build:
runs-on: ubuntu-latest
env:
# Use native docker command within docker-compose
COMPOSE_DOCKER_CLI_BUILD: 1
# Use buildkit to speed up docker command
DOCKER_BUILDKIT: 1
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.extract_branch.outputs.branch }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build full project via docker-compose
run: |
mv example.env .env
sed -i 's/docker.io/ghcr.io/g' docker-compose.yml
sed -i 's/compdem/civictechto/g' docker-compose.yml
docker compose --profile postgres build --parallel --build-arg GIT_HASH=${GITHUB_SHA:0:6}
- name: Push images to GHCR
run: docker compose --profile postgres push --ignore-push-failures
- name: Push images to Docker Hub
run: |
for image in $(docker images --format='{{.Repository}}:{{.Tag}}'); do
IMAGE_NAME=$(echo "$image" | sed 's/ghcr.io/docker.io/g')
IMAGE_NAME=$(echo "$IMAGE_NAME" | sed 's/civictechto/${{ secrets.DOCKER_USERNAME }}/g')
docker tag $image $IMAGE_NAME
sed -i 's/ghcr.io/docker.io/g' docker-compose.yml
sed -i 's/civictechto/${{ secrets.DOCKER_USERNAME }}/g' docker-compose.yml
done
docker compose --profile postgres push --ignore-push-failures