-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (53 loc) · 2.01 KB
/
oci.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
name: Build and Push WordPress Images
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Build Docker Images
run: |
nix build .#wordpress-php82 .#wordpress-php83 .#wordpress-php84
docker load < result
docker load < result-1
docker load < result-2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
# Get the actual image names from Docker
IMAGES=($(docker images --format "{{.Repository}}:{{.Tag}}" | grep wordpress))
for IMAGE in "${IMAGES[@]}"; do
PHP_VERSION=$(echo $IMAGE | sed -n 's/.*-php\([0-9]\+\).*/\1/p')
FULL_IMAGE_ID=$IMAGE_ID:php$PHP_VERSION
docker tag $IMAGE $FULL_IMAGE_ID
docker push $FULL_IMAGE_ID
done
# Tag one version as the default latest
DEFAULT_PHP_VERSION=83
docker tag $IMAGE_ID:php$DEFAULT_PHP_VERSION $IMAGE_ID:latest
docker push $IMAGE_ID:latest