Skip to content

Commit 661f628

Browse files
committed
Add GitHub actions to automate image generation
Help reviewing pull requests by verify that the image builds and streamline publishing images from releases.
1 parent 2449f64 commit 661f628

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

Diff for: .github/workflows/publish-docker-image.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
env:
8+
# GitHub repository is basically "$org/$repo"
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
# User triggering the action is authenticated to the container registry
23+
- name: Log in to the Container registry
24+
uses: docker/[email protected]
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
# Basically sets the image tag from the release
31+
- name: Extract metadata for Docker
32+
id: meta
33+
uses: docker/[email protected]
34+
with:
35+
images: ghcr.io/${{ env.IMAGE_NAME }}
36+
37+
- name: Build and push Docker image
38+
uses: docker/[email protected]
39+
with:
40+
context: .
41+
push: true
42+
tags: ${{ steps.meta.outputs.tags }}
43+
labels: ${{ steps.meta.outputs.labels }}

Diff for: .github/workflows/try-build-docker-image.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Build Docker image.
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
- name: Build the Docker image
14+
run: docker build . --file Dockerfile

Diff for: Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN npm run lint && npm run build
1010

1111
RUN npm install -g http-server
1212

13-
ENV PORT 8000
13+
ENV PORT 8080
1414
EXPOSE $PORT
1515

16-
CMD http-server dist -p "$PORT" -d false -i false
16+
CMD http-server dist -p "$PORT" -d false

0 commit comments

Comments
 (0)