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
5 changes: 5 additions & 0 deletions .github/workflows/checkSite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ on:
pull_request:
paths:
- "site/**"
- "firebase/**"
push:
paths:
- "site/**"
- "firebase/**"
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -38,6 +40,9 @@ jobs:
- name: Lint site content
run: npm i && npm run lint-check
working-directory: site
- name: Lint firebase functions
run: npm i && npm run lint
working-directory: firebase/functions
# - name: Install Site Checker
# run: yarn install
# working-directory: href-checker
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/firebase-functions-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Deploy to Firebase Functions on merge
on:
push:
branches:
- main
paths:
- "firebase/**"
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Deploy firebase functions
run: |
npm install -g firebase-tools
firebase deploy --only functions
env:
FIREBASE_TOKEN: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_KPT_DEV }}"
28 changes: 14 additions & 14 deletions firebase/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ const functions = require("firebase-functions");

// Return meta tag for remote go import path
// See: https://pkg.go.dev/cmd/go#hdr-Remote_import_paths
const remoteGoImport = ({ importPrefix, vcs, repoRoot }) => {
const remoteGoImport = ({importPrefix, vcs, repoRoot}) => {
return `<meta name="go-import" content="${importPrefix} ${vcs} ${repoRoot}">`;
}
};

// Creates a firebase endpoint which implements a golang vanity server
const vanityGoEndpoint = ({ importPrefix, vcs, repoRoot }) =>
functions.https.onRequest((request, response) => {
if (request.query["go-get"] === "1") {
return response.send(
remoteGoImport({ importPrefix, vcs, repoRoot })
);
}
return response.redirect(repoRoot);
});
const vanityGoEndpoint = ({importPrefix, vcs, repoRoot}) =>
functions.https.onRequest((request, response) => {
if (request.query["go-get"] === "1") {
return response.send(
remoteGoImport({importPrefix, vcs, repoRoot})
);
}
return response.redirect(repoRoot);
});

exports.configsync = vanityGoEndpoint({
importPrefix: 'kpt.dev/configsync',
vcs: 'git',
repoRoot: 'https://github.com/GoogleContainerTools/kpt-config-sync.git'
importPrefix: "kpt.dev/configsync",
vcs: "git",
repoRoot: "https://github.com/GoogleContainerTools/kpt-config-sync.git",
});

exports.resourcegroup = vanityGoEndpoint({
Expand Down
2 changes: 1 addition & 1 deletion firebase/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"deploy": "firebase deploy --only functions --config ../../firebase.json",
"logs": "firebase functions:log"
},
"engines": {
Expand Down