Skip to content

Commit 30d6cda

Browse files
authored
infra: simplify Makefile (#151)
* dont need to download repo locally * add make clean * build and clean * style
1 parent eca0115 commit 30d6cda

File tree

1 file changed

+11
-34
lines changed

1 file changed

+11
-34
lines changed

Makefile

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,20 @@
1616
# under the License.
1717

1818
IMAGE_NAME = df-site-build
19-
REPO_NAME = infrastructure-actions
2019

21-
.PHONY: clone-repo sync-repo build-image build
20+
.PHONY: build clean
2221

23-
all: build
24-
25-
# clones the infrastructure-actions repository
26-
clone-repo:
27-
@if [ ! -d "$(REPO_NAME)" ]; then \
28-
echo "Cloning $(REPO_NAME)..."; \
29-
git clone --depth 1 https://github.com/apache/infrastructure-actions.git $(REPO_NAME); \
30-
else \
31-
echo "$(REPO_NAME) already exists, skipping clone."; \
32-
fi
33-
34-
# syncs the repository with the latest changes from the main branch
35-
sync-repo: clone-repo
36-
@cd $(REPO_NAME) && \
37-
if [ -n "$$(git status --porcelain)" ]; then \
38-
echo "Error: Repository has uncommitted changes. Please clean the repository first."; \
39-
exit 1; \
40-
fi; \
41-
echo "Syncing with origin/main..."; \
42-
git fetch origin main && \
43-
git checkout main
44-
45-
46-
# builds the Docker image with pelicanasf installed
47-
build-image:
22+
# runs the Docker container to build the site
23+
build:
4824
@if ! docker image inspect $(IMAGE_NAME) > /dev/null 2>&1; then \
49-
echo "Building Docker image $(IMAGE_NAME)..."; \
50-
docker build -t $(IMAGE_NAME) $(REPO_NAME)/pelican; \
51-
else \
52-
echo "Docker image $(IMAGE_NAME) already exists, skipping build."; \
25+
docker build -t $(IMAGE_NAME) https://github.com/apache/infrastructure-actions.git#main:pelican; \
5326
fi
54-
55-
# runs the Docker container to build the site
56-
build: sync-repo build-image
5727
docker run -it --rm -p8000:8000 -v $(PWD):/site --entrypoint /bin/bash $(IMAGE_NAME) -c \
5828
"pelicanasf content -o blog && python3 -m http.server 8000"
29+
30+
# removes the Docker image
31+
clean:
32+
@if docker image inspect $(IMAGE_NAME) > /dev/null 2>&1; then \
33+
docker image rm -f $(IMAGE_NAME) > /dev/null 2>&1 && \
34+
echo "Removed Docker image $(IMAGE_NAME)."; \
35+
fi

0 commit comments

Comments
 (0)