Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): Publish a docker which can have its region changed #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.2.4'

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /usr/src/app
COPY package.json yarn.lock ./

# Install dependencies.
RUN yarn install
RUN apk --no-cache add git && yarn add xivapi/lodestone-css-selectors && yarn install

# Copy local code to the container image.
COPY . .
Expand All @@ -23,4 +23,4 @@ USER node
EXPOSE 8080

# Run the web service on container startup.
CMD [ "yarn", "run", "express:start" ]
CMD [ "yarn", "run", "express:start" ]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ Easy to use Node Lodestone parser.
### Inside your own server

#### Running on Host

Gather dependencies

```shell
yarn add xivapi/lodestone-css-selectors
yarn install
```

Then start
```
yarn run express:start
```

Expand Down
1 change: 1 addition & 0 deletions src/core/css-selector-registry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const PAGE_REGION = process.env.PAGE_REGION || "na"
export interface CssSelectorDefinition {
selector: string;
multiple?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/freecompany/freecompany.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Request } from "express";
import { PageParser } from "../core/page-parser";
import * as freecompany from "../lib/lodestone-css-selectors/freecompany/freecompany.json";
import { CssSelectorRegistry } from "../core/css-selector-registry";
import * as freecompany from "lodestone-css-selectors/freecompany/freecompany.json";
import { CssSelectorRegistry, PAGE_REGION } from "../core/css-selector-registry";

export class FreeCompany extends PageParser {
protected getURL(req: Request): string {
return (
"https://na.finalfantasyxiv.com/lodestone/freecompany/" + req.params.fcId
"https://"+ PAGE_REGION + ".finalfantasyxiv.com/lodestone/freecompany/" + req.params.fcId
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/freecompany/members.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request } from "express";
import { CssSelectorRegistry } from "../core/css-selector-registry";
import * as members from "../lib/lodestone-css-selectors/freecompany/members.json";
import { CssSelectorRegistry, PAGE_REGION } from "../core/css-selector-registry";
import * as members from "lodestone-css-selectors/freecompany/members.json";
import { PaginatedPageParser } from "../core/paginated-page-parser";

export class FCMembers extends PaginatedPageParser {
Expand All @@ -10,7 +10,7 @@ export class FCMembers extends PaginatedPageParser {

protected getBaseURL(req: Request): string {
return (
"https://na.finalfantasyxiv.com/lodestone/freecompany/" +
"https://"+ PAGE_REGION + ".finalfantasyxiv.com/lodestone/freecompany/" +
req.params.fcId +
"/member"
);
Expand Down
1 change: 0 additions & 1 deletion src/lib/lodestone-css-selectors
Submodule lodestone-css-selectors deleted from a6529c
6 changes: 3 additions & 3 deletions src/profile/achievements.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Request} from "express";
import {CssSelectorRegistry} from "../core/css-selector-registry";
import * as achievements from '../lib/lodestone-css-selectors/profile/achievements.json';
import {CssSelectorRegistry, PAGE_REGION} from "../core/css-selector-registry";
import * as achievements from 'lodestone-css-selectors/profile/achievements.json';
import {PaginatedPageParser} from "../core/paginated-page-parser";

export class Achievements extends PaginatedPageParser {
Expand All @@ -9,7 +9,7 @@ export class Achievements extends PaginatedPageParser {
}

protected getBaseURL(req: Request): string {
return "https://na.finalfantasyxiv.com/lodestone/character/" + req.params.characterId + "/achievement";
return "https://"+ PAGE_REGION + ".finalfantasyxiv.com/lodestone/character/" + req.params.characterId + "/achievement";
}

async parse(req: Request, columnsPrefix: string = ''): Promise<Object> {
Expand Down
10 changes: 5 additions & 5 deletions src/profile/character.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Request } from "express";
import { PageParser } from "../core/page-parser";
import * as character from "../lib/lodestone-css-selectors/profile/character.json";
import * as attributes from "../lib/lodestone-css-selectors/profile/attributes.json";
import * as gearset from "../lib/lodestone-css-selectors/profile/gearset.json";
import { CssSelectorRegistry } from "../core/css-selector-registry";
import * as character from "lodestone-css-selectors/profile/character.json";
import * as attributes from "lodestone-css-selectors/profile/attributes.json";
import * as gearset from "lodestone-css-selectors/profile/gearset.json";
import { CssSelectorRegistry, PAGE_REGION } from "../core/css-selector-registry";

export class Character extends PageParser {
protected getURL(req: Request): string {
return (
"https://na.finalfantasyxiv.com/lodestone/character/" +
"https://"+ PAGE_REGION + ".finalfantasyxiv.com/lodestone/character/" +
req.params.characterId
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/profile/classjob.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request } from "express";
import { CssSelectorRegistry } from "../core/css-selector-registry";
import * as classjob from "../lib/lodestone-css-selectors/profile/classjob.json";
import { CssSelectorRegistry, PAGE_REGION } from "../core/css-selector-registry";
import * as classjob from "lodestone-css-selectors/profile/classjob.json";
import { PaginatedPageParser } from "../core/paginated-page-parser";

export class ClassJob extends PaginatedPageParser {
Expand All @@ -10,7 +10,7 @@ export class ClassJob extends PaginatedPageParser {

protected getBaseURL(req: Request): string {
return (
"https://na.finalfantasyxiv.com/lodestone/character/" +
"https://"+ PAGE_REGION + ".finalfantasyxiv.com/lodestone/character/" +
req.params.characterId +
"/class_job"
);
Expand Down
6 changes: 3 additions & 3 deletions src/search/character-search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PaginatedPageParser } from "../core/paginated-page-parser";
import { CssSelectorRegistry } from "../core/css-selector-registry";
import * as characterSearch from "../lib/lodestone-css-selectors/search/character.json";
import { CssSelectorRegistry, PAGE_REGION } from "../core/css-selector-registry";
import * as characterSearch from "lodestone-css-selectors/search/character.json";
import { Request } from "express";
import logger from "../logger/logger";

Expand All @@ -13,7 +13,7 @@ export class CharacterSearch extends PaginatedPageParser {
} else if (req.query.server) {
query += `&worldname=${req.query.server}`;
}
return `https://na.finalfantasyxiv.com/lodestone/character/${query}`;
return `https://${PAGE_REGION}.finalfantasyxiv.com/lodestone/character/${query}`;
}

protected getCSSSelectors(): CssSelectorRegistry {
Expand Down
6 changes: 3 additions & 3 deletions src/search/freecompany-search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PaginatedPageParser } from "../core/paginated-page-parser";
import { CssSelectorRegistry } from "../core/css-selector-registry";
import * as freeCompanySearch from "../lib/lodestone-css-selectors/search/freecompany.json";
import { CssSelectorRegistry, PAGE_REGION } from "../core/css-selector-registry";
import * as freeCompanySearch from "lodestone-css-selectors/search/freecompany.json";
import { Request } from "express";
import logger from "../logger/logger";

Expand All @@ -13,7 +13,7 @@ export class FreeCompanySearch extends PaginatedPageParser {
} else if (req.query.server) {
query += `&worldname=${req.query.server}`;
}
return `https://na.finalfantasyxiv.com/lodestone/freecompany/${query}`;
return `https://${PAGE_REGION}.finalfantasyxiv.com/lodestone/freecompany/${query}`;
}

protected getCSSSelectors(): CssSelectorRegistry {
Expand Down