Skip to content

Commit 97befc1

Browse files
authored
Enable CI
1 parent f8e7f4b commit 97befc1

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

.github/workflows/build.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Build
2+
3+
on:
4+
schedule:
5+
- cron: '0 8 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
check_upstream:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
needupdated: ${{ steps.check.outputs.needupdated }}
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Check tag
16+
id: check
17+
run: |
18+
tag1=$(curl -s https://api.github.com/repos/elasticsearch-dump/elasticsearch-dump/releases/latest | jq -r '.tag_name')
19+
tag2=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r '.tag_name')
20+
echo "Latest release on elasticsearch-dump/elasticsearch-dump: $tag1"
21+
echo "Latest release on this repository: $tag2"
22+
needupdated=true
23+
if [[ "$tag1" == "$tag2" ]]; then
24+
needupdated=false
25+
fi
26+
echo "Need Updated: $needupdated"
27+
echo "needupdated=$needupdated" >> "$GITHUB_OUTPUT"
28+
build:
29+
runs-on: ubuntu-latest
30+
needs: check_upstream
31+
if: needs.check_upstream.outputs.needupdated == 'true'
32+
container:
33+
image: "centos:7"
34+
env:
35+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: actions/checkout@v3
39+
with:
40+
repository: elasticsearch-dump/elasticsearch-dump
41+
ref: master
42+
path: elasticsearch-dump
43+
- name: Cache nexe assets
44+
uses: actions/cache@v3
45+
with:
46+
path: |
47+
~/.nexe
48+
key: nexe
49+
- name: Build
50+
run: |
51+
rm -f /etc/yum.repos.d/*.repo
52+
cat << EOF >> /etc/yum.repos.d/centos.repo
53+
[base]
54+
name=CentOS-$releasever - Base
55+
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
56+
gpgcheck=0
57+
[extras]
58+
name=CentOS-$releasever - Extras
59+
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
60+
gpgcheck=0
61+
[sclorh]
62+
name=CentOS-$releasever - Sclo Rh
63+
baseurl=https://vault.centos.org/7.9.2009/sclo/x86_64/rh/
64+
gpgcheck=0
65+
EOF
66+
yum install -y unzip devtoolset-9-toolchain python3
67+
source /opt/rh/devtoolset-9/enable
68+
gcc --version
69+
curl -fsSL https://fnm.vercel.app/install | bash
70+
source $HOME/.bashrc
71+
fnm use --install-if-missing 16
72+
npm install -g nexe
73+
cd elasticsearch-dump
74+
npm install --legacy-peer-deps
75+
nexe --build -i bin/elasticdump -r "./node_modules/**/*" -r "./lib/**" -r elasticdump.js -r package.json --python /usr/bin/python3 --make="-j$(nproc 2> /dev/null || echo 1)"
76+
tar zcvf ../elasticdump_linux_amd64.tar.gz elasticdump
77+
- name: Upload build artifact
78+
uses: actions/upload-artifact@v3
79+
with:
80+
name: elasticdump_linux_amd64
81+
path: elasticdump_linux_amd64.tar.gz
82+
83+
create_release:
84+
runs-on: ubuntu-latest
85+
needs: build
86+
permissions:
87+
contents: write
88+
steps:
89+
- name: Download Artifact
90+
uses: actions/download-artifact@v3
91+
with:
92+
name: elasticdump_linux_amd64
93+
- name: Check latest tag
94+
run: |
95+
latest_tag=$(curl -s https://api.github.com/repos/elasticsearch-dump/elasticsearch-dump/releases/latest | jq -r '.tag_name')
96+
echo "Latest tag is ${latest_tag}"
97+
echo "latest_tag=${latest_tag}" >> $GITHUB_ENV
98+
- name: Create Release
99+
uses: ncipollo/release-action@v1
100+
with:
101+
tag: ${{ env.latest_tag }}
102+
body: "Built on the original repository. ${{ env.latest_tag }}"
103+
artifacts: "elasticdump_linux_amd64.tar.gz"

0 commit comments

Comments
 (0)