-
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (112 loc) · 3.81 KB
/
Copy pathmain.yaml
File metadata and controls
133 lines (112 loc) · 3.81 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Main
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
types: [ opened, synchronize ]
permissions:
contents: read
packages: write
jobs:
version:
name: Version
runs-on: ubuntu-24.04
outputs:
playwright_version: ${{ steps.playwright.outputs.version }}
docker_label: ${{ steps.docker.outputs.label }}
git_tag: ${{ steps.git.outputs.tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Extract Playwright version
id: playwright
run: |
extracted_version=$(node -p "require('./playwright-installer/package.json').dependencies['@playwright/test']")
echo "version=$extracted_version" >> $GITHUB_OUTPUT
- name: Extract Ubuntu distro codename
id: distro
run: |
from_line=$(grep '^FROM' Dockerfile)
# Extract the tag part after 'ubuntu:' and before '@' or end of line
extracted_codename=$(echo "$from_line" | sed -n 's/^FROM ubuntu:\([^@]*\).*/\1/p')
# Fallback to default if not found
codename=${extracted_codename:-noble}
echo "codename=$codename" >> $GITHUB_OUTPUT
- name: Determine Docker label
id: docker
run: |
label="v${{ steps.playwright.outputs.version }}-${{ steps.distro.outputs.codename }}"
echo "label=$label" >> $GITHUB_OUTPUT
- name: Determine Git tag
id: git
run: |
COMMIT_SHA=${GITHUB_SHA::7}
tag="${{ steps.docker.outputs.label }}-${COMMIT_SHA}"
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Summary
run: |
echo "Playwright version: ${{ steps.playwright.outputs.version }}"
echo "Docker label: ${{ steps.docker.outputs.label }}"
echo "Git tag: ${{ steps.git.outputs.tag }}"
build-test-publish:
name: "Build -> Test -> Publish"
runs-on: ubuntu-24.04
needs:
- version
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v4.0.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
id: build
uses: docker/build-push-action@v6
with:
context: .
tags: serenity-js:latest
load: true
push: false
- name: Test image
run: |
docker run --rm serenity-js:latest whoami
docker run --rm serenity-js:latest node --version
docker run --rm serenity-js:latest java --version
docker run --rm serenity-js:latest google-chrome --version
docker run --rm serenity-js:latest microsoft-edge --version
- name: Push image
if: success() && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/serenity-js/playwright:${{ needs.version.outputs.docker_label }}
tag:
name: "Tag repository"
runs-on: "ubuntu-24.04"
if: github.ref == 'refs/heads/main'
needs:
- version
- build-test-publish
permissions:
contents: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Push Git tag
env:
TAG_NAME: ${{ needs.version.outputs.git_tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Creating Git tag $TAG_NAME"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag $TAG_NAME
git push origin $TAG_NAME