Skip to content
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*
!*.js
!*.json
!/bin
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Build and push'

on:
push:
branches:
- master
tags:
- '*'

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 'Set image tag and name'
id: tag
run: |
IMAGE_TAG="master"
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
REF=${{ github.ref }};
TAG_FULL=${REF#refs/*/};
IMAGE_TAG=${TAG_FULL//\//_};
fi
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "image_name=${{ secrets.IMAGE_NAME }}" >> $GITHUB_OUTPUT

- name: 'Login to Docker Hub'
uses: docker/login-action@v2
with:
username: ${{ secrets.REGISTRY_LOGIN }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@v2

- name: 'Build and push'
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
tags: ${{steps.tag.outputs.image_name}}:${{steps.tag.outputs.image_tag}}
cache-from: type=registry,ref=${{ steps.tag.outputs.image_name }}:buildcache
cache-to: type=registry,ref=${{ steps.tag.outputs.image_name }}:buildcache,mode=max
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:14-alpine

ARG ReviewMeVersion=2
ADD . /app/
WORKDIR /app

# Workaroudn when building on an AWS EC2 c5/m5/t3 instance
# RUN npm config set unsafe-perm true
RUN npm install -g .

RUN npm install -g @trademe/reviewme@${ReviewMeVersion}
CMD reviewme
9 changes: 7 additions & 2 deletions reviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const request = require('request');
const appstore = require('./appstorereviews.js');
const googlePlay = require('./googleplayreviews.js');
const fs = require('fs');
const dataDir = "/var/lib/reviewme";

const REVIEWS_STORES = {
"APP_STORE": "app-store",
Expand All @@ -10,13 +11,17 @@ const REVIEWS_STORES = {

var published_reviews;
try {
published_reviews = JSON.parse(fs.readFileSync('./published_reviews.json'));
published_reviews = JSON.parse(fs.readFileSync(dataDir + '/published_reviews.json'));
} catch (err) {
published_reviews = {}
}

(function () {
exports.start = function start(config) {
if (!fs.existsSync(dataDir)) {
fs.mkdirSync(dataDir, { recursive: true });
}

if (!config.store) {
// Determine from which store reviews are downloaded
config.store = (config.appId.indexOf("\.") > -1) ? REVIEWS_STORES.GOOGLE_PLAY : REVIEWS_STORES.APP_STORE;
Expand Down Expand Up @@ -52,7 +57,7 @@ exports.markReviewAsPublished = function (config, review) {
console.log("INFO: Review marked as published: " + JSON.stringify(published_reviews[config.appId]));
}

fs.writeFileSync('./published_reviews.json', JSON.stringify(published_reviews), { flag: 'w' })
fs.writeFileSync(dataDir + '/published_reviews.json', JSON.stringify(published_reviews), { flag: 'w' })
};

exports.reviewPublished = function (config, review) {
Expand Down