Skip to content

Commit 9c1a440

Browse files
committed
Support testing external PRs
1 parent daedc9e commit 9c1a440

File tree

2 files changed

+275
-139
lines changed

2 files changed

+275
-139
lines changed

.github/workflows/pull.yml

Lines changed: 28 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Push Pull Requests
1+
name: Build Pull Request
22

33
on:
44
pull_request:
@@ -11,7 +11,7 @@ env:
1111
PHP_TZ: 'UTC'
1212

1313
jobs:
14-
multiarch:
14+
build:
1515
runs-on: ubuntu-latest
1616
steps:
1717
-
@@ -24,150 +24,39 @@ jobs:
2424
name: Set up Docker Buildx
2525
uses: docker/setup-buildx-action@v2
2626
-
27-
name: Login to DockerHub
28-
uses: docker/login-action@v2
29-
with:
30-
username: ${{ secrets.DOCKERHUB_USERNAME }}
31-
password: ${{ secrets.DOCKERHUB_TOKEN }}
32-
-
33-
name: Build and push
27+
name: Test multiarch building
3428
uses: docker/build-push-action@v3
3529
with:
3630
context: .
3731
file: ./Dockerfile
3832
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
39-
push: true
33+
load: false
34+
push: false
4035
tags: |
4136
lycheeorg/lychee:testing-${{ github.run_id }}
42-
43-
default-env:
44-
needs: multiarch
45-
runs-on: ubuntu-latest
46-
services:
47-
lychee-docker:
48-
image: lycheeorg/lychee:testing-${{ github.run_id }}
49-
ports:
50-
- 80:80
51-
steps:
52-
-
53-
name: GET
54-
run: 'curl -sSw "%{stderr}%{http_code}" http://localhost/ > /dev/null && curl -f http://localhost/'
55-
56-
sqlite:
57-
needs: multiarch
58-
runs-on: ubuntu-latest
59-
services:
60-
lychee-docker:
61-
image: lycheeorg/lychee:testing-${{ github.run_id }}
62-
ports:
63-
- 80:80
64-
env:
65-
DB_CONNECTION: sqlite
66-
steps:
67-
-
68-
name: GET
69-
run: 'curl -sSw "%{stderr}%{http_code}" http://localhost/ > /dev/null && curl -f http://localhost/'
70-
71-
sqlite2:
72-
needs: multiarch
73-
runs-on: ubuntu-latest
74-
services:
75-
lychee-docker:
76-
image: lycheeorg/lychee:testing-${{ github.run_id }}
77-
ports:
78-
- 80:80
79-
env:
80-
DB_CONNECTION: sqlite
81-
DB_DATABASE: '/var/www/html/Lychee/nonexistent'
82-
steps:
83-
-
84-
name: GET
85-
run: 'curl -sSw "%{stderr}%{http_code}" http://localhost/ > /dev/null && curl -f http://localhost/'
86-
87-
mysql:
88-
needs: multiarch
89-
runs-on: ubuntu-latest
90-
services:
91-
lychee-docker:
92-
image: lycheeorg/lychee:testing-${{ github.run_id }}
93-
ports:
94-
- 80:80
95-
db:
96-
image: mariadb:latest
97-
env:
98-
MYSQL_ROOT_PASSWORD: password
99-
MYSQL_DATABASE: lychee
100-
env:
101-
DB_CONNECTION: mysql
102-
DB_HOST: db
103-
DB_PORT: '3306'
104-
DB_DATABASE: lychee
105-
DB_USERNAME: root
106-
DB_PASSWORD: password
107-
steps:
108-
-
109-
name: GET
110-
run: 'curl -sSw "%{stderr}%{http_code}" http://localhost/ > /dev/null && curl -f http://localhost/'
111-
112-
postgres:
113-
needs: multiarch
114-
runs-on: ubuntu-latest
115-
services:
116-
lychee-docker:
117-
image: lycheeorg/lychee:testing-${{ github.run_id }}
118-
ports:
119-
- 80:80
120-
db:
121-
image: postgres:latest
122-
env:
123-
POSTGRES_PASSWORD: password
124-
POSTGRES_DB: lychee
125-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
126-
env:
127-
DB_CONNECTION: pgsql
128-
DB_HOST: db
129-
DB_PORT: '5432'
130-
DB_DATABASE: lychee
131-
DB_USERNAME: postgres
132-
DB_PASSWORD: password
133-
steps:
13437
-
135-
name: GET
136-
run: 'curl -sSw "%{stderr}%{http_code}" http://localhost/ > /dev/null && curl -f http://localhost/'
137-
138-
docker-compose:
139-
needs: multiarch
140-
runs-on: ubuntu-latest
141-
services:
142-
lychee-docker:
143-
image: lycheeorg/lychee:testing-${{ github.run_id }}
144-
ports:
145-
- 80:80
146-
steps:
147-
-
148-
name: Checkout
149-
uses: actions/checkout@v3
150-
-
151-
name: Set Password
152-
run: "sed -i 's/<.*_PASSWORD>/password/g' docker-compose.yml"
153-
-
154-
name: Set Image
155-
run: "sed -i 's|image: lycheeorg/lychee|image: lycheeorg/lychee:testing-${{ github.run_id }}|' docker-compose.yml"
156-
-
157-
name: Install docker-compose
158-
run: "sudo apt install docker-compose"
159-
-
160-
name: Run docker-compose
161-
run: 'docker-compose up -d && sleep 45 && docker-compose ps && curl -sSw "%{stderr}%{http_code}" http://localhost:90/ > /dev/null && curl -f http://localhost:90/'
162-
163-
retag:
164-
needs: [default-env, sqlite, sqlite2, mysql, postgres, docker-compose]
165-
runs-on: ubuntu-latest
166-
container:
167-
image: gcr.io/go-containerregistry/crane:debug
168-
steps:
38+
name: Save amd64 image to pass to testing
39+
uses: docker/build-push-action@v3
40+
with:
41+
context: .
42+
file: ./Dockerfile
43+
platforms: linux/amd64
44+
load: true
45+
push: false
46+
tags: |
47+
lycheeorg/lychee:testing-${{ github.run_id }}
16948
-
170-
name: Retag image
49+
name: Export Image and PR Number
17150
run: |
172-
crane auth login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} index.docker.io
173-
crane tag lycheeorg/lychee:testing-${{ github.run_id }} testing-pull${{ github.event.pull_request.number }}
51+
mkdir -p ./artifact
52+
docker image save -o ./artifact/lychee.tar lycheeorg/lychee:testing-${{ github.run_id }}
53+
echo "${{ github.event.number }}" > ./artifact/pr
54+
echo "${{ github.sha }}" > ./artifact/sha
55+
echo -e "PR: ${{ github.event.number }}\nSHA: ${{ github.sha }}\nBase ref: ${{ github.base_ref }}\nHead ref: ${{ github.head_ref }}"
56+
sha256sum artifact/lychee.tar || echo 0
57+
-
58+
name: Store as artifact
59+
uses: actions/upload-artifact@v3
60+
with:
61+
name: artifact
62+
path: ./artifact

0 commit comments

Comments
 (0)