Skip to content

Commit aa8e65b

Browse files
committed
get closer to standardizing the actions setup
Update the GitHub Actions configs to try to get closer to a standard setup we can use across multiple repos. Switch from jamestrousdale/github-app-jwt-token to actions/create-github-app-token. Should be more trustworthy and likely better maintained. Use docker/build-push-action for building docker images rather than running the commands manually. Use docker/metadata-action to provide extra metadata, as well as picking the tags we will push. This allows combining the 'deployment' and 'production' build workflows. Update the perl and node versions used when testing without Docker to match the versions used in Docker.
1 parent 5528deb commit aa8e65b

File tree

6 files changed

+87
-97
lines changed

6 files changed

+87
-97
lines changed

.github/workflows/automerge.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Maybe Enable Auto-Merge
1+
name: Enable Auto-Merge For metacpan-automation
22
on:
33
pull_request_target:
44
types: [opened]
@@ -9,12 +9,12 @@ jobs:
99
if: github.event.pull_request.user.login == 'metacpan-automation[bot]'
1010
steps:
1111
- name: Generate Auth Token
12-
id: auth-token
13-
uses: jamestrousdale/github-app-jwt-token@0.1.4
12+
uses: actions/create-github-app-token@v1
13+
id: app-token
1414
with:
1515
app-id: ${{ secrets.APP_ID }}
1616
private-key: ${{ secrets.APP_PRIVATE_KEY }}
1717
- uses: peter-evans/enable-pull-request-automerge@v3
1818
with:
19-
token: ${{ steps.auth-token.outputs.access-token }}
19+
token: ${{ steps.app-token.outputs.token }}
2020
pull-request-number: ${{ github.event.pull_request.number }}

.github/workflows/build-container.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build container
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- staging
7+
- prod
8+
pull_request:
9+
branches:
10+
- master
11+
workflow_dispatch:
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-22.04
15+
name: Docker Build and Push
16+
steps:
17+
- name: Generate Auth Token
18+
uses: actions/create-github-app-token@v1
19+
id: app-token
20+
with:
21+
app-id: ${{ secrets.APP_ID }}
22+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
23+
- name: Log in to Docker Hub
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_HUB_USER }}
27+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
- uses: actions/checkout@v4
31+
token: ${{ steps.app-token.outputs.token }}
32+
- name: Build test image
33+
id: docker-build-test
34+
uses: docker/build-push-action@v5
35+
with:
36+
target: test
37+
push: false
38+
load: true
39+
- name: Run Perl tests
40+
run: docker run -i ${{ steps.docker-build-test.outputs.imageid }}
41+
- name: Docker meta
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ github.repository }}
46+
flavor: |
47+
latest=false
48+
tags: |
49+
type=sha,format=long,priority=2000
50+
type=ref,event=branch
51+
type=ref,event=pr
52+
type=raw,value=latest,enable={{is_default_branch}}
53+
- name: Build and push
54+
uses: docker/build-push-action@v5
55+
with:
56+
push: true
57+
tags: ${{ steps.meta.outputs.tags }}
58+
annotations: ${{ steps.meta.outputs.annotations }}
59+
- name: Update deployed image
60+
if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }}
61+
uses: benc-uk/workflow-dispatch@v1
62+
with:
63+
repo: metacpan/metacpan-k8s
64+
ref: main
65+
workflow: set-image.yml
66+
token: ${{ steps.app-token.outputs.token }}
67+
inputs: '{ "app": "web", "environment": "prod", "base-tag": "${{ github.repository }}:latest", "tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}" }'

.github/workflows/build-deployment-container.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/build-production-container.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ jobs:
1414
runs-on: ubuntu-22.04
1515
name: Docker
1616
steps:
17-
- uses: actions/checkout@v4
18-
- name: docker build
19-
run: docker build . --target test -t metacpan/metacpan-web:latest
20-
- name: run Perl tests
21-
run: >
22-
docker run -i metacpan/metacpan-web
23-
carton exec prove -lr --jobs 2 t
17+
- name: Build test image
18+
id: docker-build-test
19+
uses: docker/build-push-action@v5
20+
with:
21+
target: test
22+
push: false
23+
load: true
24+
- name: Run Perl tests
25+
run: docker run -i ${{ steps.docker-build-test.outputs.imageid }}
2426
test:
2527
runs-on: ubuntu-20.04
2628
name: Dockerless
2729
strategy:
2830
fail-fast: false
2931
matrix:
3032
perl-version:
31-
- "5.30"
33+
- "5.36"
3234
resolver:
3335
- snapshot
3436
- metacpan
@@ -40,7 +42,7 @@ jobs:
4042
- uses: actions/checkout@v4
4143
- uses: actions/setup-node@v4
4244
with:
43-
node-version: "18"
45+
node-version: "22"
4446
- run: npm install
4547
- run: apt-get update && apt-get -y install libcmark-dev
4648
- name: Install Carton

.github/workflows/update-snapshot.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ jobs:
88
runs-on: "ubuntu-20.04"
99
steps:
1010
- name: Generate Auth Token
11-
id: auth-token
12-
uses: jamestrousdale/github-app-jwt-token@0.1.4
11+
uses: actions/create-github-app-token@v1
12+
id: app-token
1313
with:
1414
app-id: ${{ secrets.APP_ID }}
1515
private-key: ${{ secrets.APP_PRIVATE_KEY }}
1616
- id: git-user
1717
name: Set up git user
1818
uses: haarg/setup-git-user@v1
1919
with:
20-
jwt: ${{ steps.auth-token.outputs.jwt }}
20+
app: ${{ steps.app-token.outputs.app-slug }}
2121
- uses: actions/checkout@v4
2222
with:
23-
token: ${{ steps.auth-token.outputs.access-token }}
23+
token: ${{ steps.app-token.outputs.token }}
2424
- name: Set up installation local::lib
2525
run: |
2626
mkdir -p $RUNNER_TEMP/perl5/bin
@@ -69,7 +69,7 @@ jobs:
6969
- name: Create Pull Request
7070
uses: peter-evans/create-pull-request@v6
7171
with:
72-
token: ${{ steps.auth-token.outputs.access-token }}
72+
token: ${{ steps.app-token.outputs.token }}
7373
commit-message: Update cpanfile.snapshot
7474
title: Update cpanfile.snapshot
7575
author: ${{ steps.git-user.outputs.user-full }}

0 commit comments

Comments
 (0)