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

Commit

Permalink
Merge pull request #24 from trisbee/release-test
Browse files Browse the repository at this point in the history
release test
  • Loading branch information
HamAndRock authored Jan 25, 2021
2 parents 519aa47 + 18d0db3 commit c422878
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
docker build . --tag eu.gcr.io/${{ secrets.PRODUCTION_PROJECT }}/${{ secrets.PRODUCTION_SERVICE }}:latest
- name: 'Authenticate into Google Cloud Platform'
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@master
with:
service_account_email: ${{ secrets.GCLOUD_EMAIL }}
service_account_key: ${{ secrets.GCLOUD_AUTH }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
DOCKER_IMG: eu.gcr.io/trisbee-staging/fe-cloud-run-example:${{ github.event.number }}
steps:
- name: 'Google Cloud setup'
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@master
with:
version: '306.0.0'
project_id: ${{ env.PROJECT_NAME }}
Expand All @@ -40,4 +40,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
append: true
message: |
Service URL ${{ env.SERVICE_URL }} deleted.
Service URL ${{ env.SERVICE_URL }} deleted.
3 changes: 2 additions & 1 deletion .github/workflows/pull-request-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
env:
REGION: europe-west1
PROJECT_NAME: trisbee-staging
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
SERVICE_NAME: fe-cloud-run-example-pr-${{ github.event.number }}
DOCKER_IMG: eu.gcr.io/trisbee-staging/fe-cloud-run-example:PR-${{ github.event.number }}-${{ github.sha }}
APP_PORT: 3000
Expand All @@ -23,7 +24,7 @@ jobs:
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" -n 1 > ./src/commit.txt
- name: 'Google Cloud setup'
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@master
with:
version: '306.0.0'
project_id: ${{ env.PROJECT_NAME }}
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on:
release:
types: [published]

jobs:
stage:
name: 'Production release'
runs-on: ubuntu-latest
env:
REGION: europe-west1
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
PROJECT_NAME: trisbee-staging
SERVICE_NAME: fe-cloud-run-example
DOCKER_IMG: eu.gcr.io/trisbee-staging/fe-cloud-run-example:latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2

- name: 'Get Previous tag'
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1

- name: 'Google Cloud setup'
uses: google-github-actions/setup-gcloud@master
with:
version: '306.0.0'
project_id: ${{ env.PROJECT_NAME }}
service_account_key: ${{ secrets.FE_STAGE_GCP_SA_KEY }}
export_default_credentials: true

- name: 'Build Docker image'
env:
RELEASE_VERSION: ${{ steps.previoustag.outsputs.tag }}
run: docker build --tag ${{ env.DOCKER_IMG }} .

- name: 'Push Docker image to Google Cloud'
run: |
gcloud auth configure-docker
docker push ${{ env.DOCKER_IMG }}
- name: 'Deploy new revision in Google Cloud Run'
run: |
gcloud run deploy ${{ env.SERVICE_NAME }} \
--image ${{ env.DOCKER_IMG }} \
--project ${{ env.PROJECT_NAME }} \
--region ${{ env.REGION }} \
--quiet \
--platform managed
4 changes: 2 additions & 2 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v2

- name: 'Google Cloud setup'
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@master
with:
version: '306.0.0'
project_id: ${{ env.PROJECT_NAME }}
Expand All @@ -38,4 +38,4 @@ jobs:
--project ${{ env.PROJECT_NAME }} \
--region ${{ env.REGION }} \
--quiet \
--platform managed
--platform managed
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ WORKDIR /usr/src/app
# where available (npm@5+)
COPY package*.json ./

RUN npm install
ARG RELEASE_VERSION
ENV RELEASE_VERSION $RELEASE_VERSION

RUN npm ci
# If you are building your code for production
# RUN npm ci --only=production
# Install production dependencies.
Expand All @@ -24,4 +27,4 @@ COPY .git/ ./.git/


# Start the server app using Node.js
CMD ["npm", "run", "start"]
CMD ["npm", "run", "start"]
2 changes: 2 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const GC_revision = process.env.K_REVISION || 'not set';
const GC_service = process.env.K_SERVICE || 'not set';
const GC_project = process.env.K_PROJECT || 'not set';
const GC_region = process.env.K_REGION || 'not set';
const RELEASE_VERSION = process.env.RELEASE_VERSION || 'not set';
const cloudURL = `https://console.cloud.google.com/run/detail/${GC_region}/${GC_service}/revisions&project=${GC_project}`;

let commitMessage = fs.readFileSync(path.join(__dirname, 'commit.txt'), {encoding: 'utf8', flag: 'r'});
Expand All @@ -36,6 +37,7 @@ app.get('/', (req, res) => {
<h2>GIT data:</h2>
<pre>${commitMessage}</pre>
<h3>${RELEASE_VERSION}</h3>
`;

res.send(response);
Expand Down

0 comments on commit c422878

Please sign in to comment.