Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Use node 18 and fix cache folder issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rolu01 authored Jan 22, 2024
2 parents a975f3c + 4df37b9 commit b1e2d42
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 4,778 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build branch

on:
push:
branches-ignore:
- main

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test
build-latest:
name: Build branch
runs-on: ubuntu-latest
env:
PROJECT_ID: ${{ secrets.GCP_BUILD_PROJECT_ID }}

steps:
- name: Checkout
uses: actions/checkout@v3

- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
- uses: google-github-actions/setup-gcloud@v0
with:
version: "286.0.0"
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}

- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's/\//-/g')" >> $GITHUB_OUTPUT
id: extract_branch

- name: Build
run: |-
gcloud builds submit \
--quiet \
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.extract_branch.outputs.branch }}"
48 changes: 24 additions & 24 deletions .github/workflows/build-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@ name: Build latest

on:
push:
branches: [ main ]
branches: [main]

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16
uses: actions/setup-node@v1
with:
node-version: 16
- run: npm ci
- run: npm test
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test
build-latest:
name: Build latest
runs-on: ubuntu-latest
env:
PROJECT_ID: ${{ secrets.GCP_BUILD_PROJECT_ID }}

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
- uses: google-github-actions/setup-gcloud@v0
with:
version: '286.0.0'
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}
- uses: google-github-actions/setup-gcloud@v0
with:
version: "286.0.0"
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}

- name: Build
run: |-
gcloud builds submit \
--quiet \
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:latest"
- name: Build
run: |-
gcloud builds submit \
--quiet \
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:latest"
95 changes: 47 additions & 48 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ name: Build release
on:
push:
tags:
- 'v*'

- "v*"

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16
uses: actions/setup-node@v1
with:
node-version: 16
- run: npm ci
- run: npm test
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test
build:
name: Build with google cloud
runs-on: ubuntu-latest
Expand All @@ -26,50 +25,50 @@ jobs:

# Extract version tags from tag
steps:
- name: Setup variables
id: variables
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
FULL_V_TAG=$(echo $TAG_NAME | sed -r 's/^v(.+)/\1/')
MINOR_V_TAG=$(echo $FULL_V_TAG | sed -r -e 's/.*-(\w+)/\1/' -e 's/(^[0-9]+\.[0-9]+).*/\1/')
MAJOR_V_TAG=$(echo $MINOR_V_TAG | sed -r -e 's/(^[a-z]+).*/\1/' -e 's/(^[0-9]+).*/\1/')
- name: Setup variables
id: variables
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
FULL_V_TAG=$(echo $TAG_NAME | sed -r 's/^v(.+)/\1/')
MINOR_V_TAG=$(echo $FULL_V_TAG | sed -r -e 's/.*-(\w+)/\1/' -e 's/(^[0-9]+\.[0-9]+).*/\1/')
MAJOR_V_TAG=$(echo $MINOR_V_TAG | sed -r -e 's/(^[a-z]+).*/\1/' -e 's/(^[0-9]+).*/\1/')
echo ::set-output name=full_version_tag::$FULL_V_TAG
echo ::set-output name=minor_version_tag::$MINOR_V_TAG
echo ::set-output name=major_version_tag::$MAJOR_V_TAG
echo ::set-output name=full_version_tag::$FULL_V_TAG
echo ::set-output name=minor_version_tag::$MINOR_V_TAG
echo ::set-output name=major_version_tag::$MAJOR_V_TAG
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0
with:
version: '286.0.0'
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0
with:
version: "286.0.0"
project_id: ${{ secrets.GCP_BUILD_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_EMAIL }}
service_account_key: ${{ secrets.GCP_BUILD_SERVICE_ACCOUNT_KEY }}

# Build and push image to Google Container Registry
- name: Build
run: |-
gcloud builds submit \
--quiet \
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA"
# Build and push image to Google Container Registry
- name: Build
run: |-
gcloud builds submit \
--quiet \
--tag "eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA"
- name: Tag image
run: |-
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.full_version_tag }}"
- name: Tag image
run: |-
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.full_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.minor_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.minor_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.major_version_tag }}"
gcloud container images add-tag --quiet \
"eu.gcr.io/$PROJECT_ID/hub/functions:$GITHUB_SHA" \
"eu.gcr.io/$PROJECT_ID/hub/functions:${{ steps.variables.outputs.major_version_tag }}"
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:18-alpine

# Labels
LABEL vendor="Onify"
Expand All @@ -7,6 +7,9 @@ LABEL code="nodejs"
# Create app directory
RUN mkdir -p /usr/app

# Added this config because of bug in node18 alpine image https://github.com/nodejs/docker-node/issues/1749
ENV npm_config_cache /tmp/npm

WORKDIR /usr/app

COPY ./functions ./functions
Expand All @@ -22,4 +25,4 @@ RUN npm prune --production

ENV NODE_ENV=production

ENTRYPOINT [ "npm", "start", "--silent" ]
ENTRYPOINT [ "npm", "start" ]
Loading

0 comments on commit b1e2d42

Please sign in to comment.