-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5ce397a
Showing
69 changed files
with
23,720 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Build and Publish Go Binaries | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.22 | ||
|
||
- name: Build binaries | ||
run: | | ||
make build | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
files: | | ||
scraper | ||
api | ||
mailer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Build and test frontend | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build-and-test-frontend: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [21.x] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: frontend/node_modules | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Install and build frontend | ||
run: make build-frontend | ||
|
||
- name: Test frontend | ||
run: make test-frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Go Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_USER: test | ||
POSTGRES_PASSWORD: Test1234 | ||
POSTGRES_DB: test | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.22' | ||
|
||
- name: Run tests | ||
run: make test-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
venv/ | ||
config/*.yaml | ||
!config/config.example.yaml | ||
.github/workflows/deploy-frontend.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "scraper", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"env": { | ||
"SHOPSCRAPER_DB_CONNECTION_STRING": "postgresql://test:Test1234@localhost:5432/test?sslmode=disable", | ||
}, | ||
"program": "${workspaceFolder}/cmd/scraper/main.go", | ||
"args": ["--config-path", "config/config.yaml"], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "mailer", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"env": { | ||
"SHOPSCRAPER_DB_CONNECTION_STRING": "postgresql://test:Test1234@localhost:5432/test?sslmode=disable", | ||
"SHOPSCRAPER_SMTP_PASSWORD": "test" | ||
}, | ||
"program": "${workspaceFolder}/cmd/mailer/main.go", | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "api", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"env": { | ||
"SHOPSCRAPER_DB_CONNECTION_STRING": "postgresql://test:Test1234@localhost:5432/test?sslmode=disable", | ||
"SHOPSCRAPER_API_KEY": "Test1234" | ||
}, | ||
"program": "${workspaceFolder}/cmd/api/main.go", | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Use an official Golang runtime as a parent image | ||
FROM golang:1.22 AS build | ||
|
||
# Set the working directory in the container | ||
WORKDIR /go/src/app | ||
|
||
# Copy the current directory contents into the container | ||
COPY . . | ||
|
||
# Build the Go app | ||
RUN make build | ||
|
||
# Start a new stage from scratch | ||
FROM debian:bookworm-slim | ||
|
||
# Install PostgreSQL client and dependencies for Chrome | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
wget \ | ||
gnupg \ | ||
ca-certificates \ | ||
fonts-liberation \ | ||
libappindicator3-1 \ | ||
libasound2 \ | ||
libatk-bridge2.0-0 \ | ||
libatk1.0-0 \ | ||
libcups2 \ | ||
libdbus-1-3 \ | ||
libgdk-pixbuf2.0-0 \ | ||
libnspr4 \ | ||
libnss3 \ | ||
libx11-xcb1 \ | ||
libxcomposite1 \ | ||
libxdamage1 \ | ||
libxrandr2 \ | ||
xdg-utils \ | ||
libxss1 \ | ||
libxtst6 \ | ||
unzip \ | ||
--no-install-recommends && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Use ARG to define the architecture dynamically at build time | ||
ARG TARGETARCH | ||
|
||
# Install Google Chrome or Chromium based on architecture | ||
RUN if [ "$TARGETARCH" = "amd64" ]; then \ | ||
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ | ||
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ | ||
apt-get update && apt-get install -y google-chrome-stable; \ | ||
elif [ "$TARGETARCH" = "arm64" ]; then \ | ||
apt-get update && apt-get install -y chromium; \ | ||
else \ | ||
echo "Unsupported architecture"; \ | ||
exit 1; \ | ||
fi | ||
|
||
# Set Chrome/Chromium as the headless browser for ChromeDP based on architecture | ||
ENV CHROME_PATH=/usr/bin/google-chrome | ||
RUN if [ "$TARGETARCH" = "arm64" ]; then \ | ||
export CHROME_PATH=/usr/bin/chromium; \ | ||
fi | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the built executable from the previous stage | ||
COPY --from=build /go/src/app/scraper . | ||
COPY --from=build /go/src/app/api . | ||
COPY --from=build /go/src/app/mailer . | ||
|
||
COPY scripts/wait-for-it.sh /wait-for-it.sh | ||
RUN chmod +x /wait-for-it.sh | ||
|
||
|
||
# Run the Go app | ||
CMD ["./scraper"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2024 Pontus Wiberg | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.