-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (98 loc) · 3.34 KB
/
docker-image-elasticsearch.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Docker Image Elasticsearch
on:
schedule:
- cron: "0 3 * * 0" # At 03:00 on Sunday
push:
branches:
- 'main'
paths:
- version
- images/elasticsearch/**
- .github/workflows/*elasticsearch*
jobs:
build-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: echo "matrix=${{ vars.ELASTICSEARCH_MATRIX }}" >> $GITHUB_OUTPUT
- run: echo "Matrix:\n";echo '${{ steps.set-matrix.outputs.matrix }}'
elasticsearch:
needs: build-matrix
name: Elasticsearch
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ !env.ACT }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: ${{ !env.ACT }}
- name: Set build-args
run: |-
ESCAPED_VERSION="$(echo ${{ matrix.version }} | sed 's/\./\\\./g')"
ES_VERSION=$(
curl -s curl -s https://hub.docker.com/v2/repositories/library/elasticsearch/tags/?page_size=200 \
| jq -r '.results[].name' \
| egrep "^${ESCAPED_VERSION}\.[0-9]+(\.[0-9]+)?\$" | sort -Vr | head -n1
)
echo "ES_VERSION=${ES_VERSION}" | tee /dev/stderr >> $GITHUB_ENV
- uses: docker/build-push-action@v6
with:
context: images/elasticsearch
platforms: linux/amd64,linux/arm64
build-args: ES_VERSION=${{ env.ES_VERSION }}
push: ${{ github.ref == 'refs/heads/main' && !env.ACT }}
tags: ghcr.io/${{ github.repository_owner }}/elasticsearch:${{ matrix.version }}
delete-versions:
name: Delete versions
needs: [ elasticsearch ]
runs-on: ubuntu-latest
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: 'elasticsearch'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
update-readme:
needs: [ elasticsearch ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: npm install axios
- name: Update README.md
run: node .github/workflows/actions/readme-update.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGE_NAME: Elasticsearch
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
if [ -n "$(git status --porcelain)" ]; then
git commit -m "Update Elasticsearch versions in README.md"
git push
else
echo "No changes to commit"
fi