Skip to content

Commit a78cef4

Browse files
authored
Merge pull request #2 from stuartleeks/sl/devcontainer-action
Add initial GitHub action for build
2 parents ab485fc + f8d06bd commit a78cef4

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ ARG USERNAME=vscode
3131
ARG USER_UID=1000
3232
ARG USER_GID=$USER_UID
3333

34+
# Set env for tracking that we're running in a devcontainer
35+
ENV DEVCONTAINER=true
3436

3537
# Enable go modules
3638
ENV GO111MODULE=on

.github/workflows/build.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-18.04
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: CI Tooling
17+
run: sudo apt update && sudo apt install build-essential -y
18+
19+
- name: Build devcontainer for tooling
20+
run: sudo -E make devcontainer
21+
22+
- name: Run the build
23+
run: sudo -E make devcontainer-build

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@ build:
22
go build ./cmd/devcontainer
33

44
devcontainer:
5-
docker build -f ./.devcontainer/Dockerfile ./.devcontainer -t devcontainer-cli
5+
docker build -f ./.devcontainer/Dockerfile ./.devcontainer -t devcontainer-cli
6+
7+
8+
devcontainer-build:
9+
ifdef DEVCONTAINER
10+
$(error This target can only be run outside of the devcontainer as it mounts files and this fails within a devcontainer. Don't worry all it needs is docker)
11+
endif
12+
@docker run -v ${PWD}:${PWD} \
13+
--entrypoint /bin/bash \
14+
--workdir "${PWD}" \
15+
devcontainer-cli \
16+
-c "make build"

0 commit comments

Comments
 (0)