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
20 changes: 20 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
on:
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_GITHUBACTIONPRACTICE_F87C3 }}
channelId: live
projectId: githubactionpractice-f87c3
21 changes: 21 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
on: pull_request
permissions:
checks: write
contents: read
pull-requests: write
jobs:
build_and_preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_GITHUBACTIONPRACTICE_F87C3 }}
projectId: githubactionpractice-f87c3
8 changes: 4 additions & 4 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ name: Node Continuous Integration

on:
pull_request:
branches: [ main ]

branches: [main]

jobs:
test_pull_request:
Expand All @@ -16,10 +15,11 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 21
registry-url: "https://registry.npmjs.org/"
- run: npm ci
- run: npm test
- run: npm run build
- run: npm ci
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}
3 changes: 3 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const crypto = require('crypto');
const crypto_orig_createHash = crypto.createHash;
crypto.createHash = algorithm => crypto_orig_createHash(algorithm === 'md4' ? 'sha256' : algorithm);
49 changes: 0 additions & 49 deletions firebase-debug.log

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "devops",
"name": "devops-5821",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest",
"build": "webpack src/app.js -o public/bundle.js",
"build": "set NODE_OPTIONS=--openssl-legacy-provider && webpack --config config.js src/app.js -o public/bundle.js",
"start": "set NODE_OPTIONS=--openssl-legacy-provider",
"deploy": "firebase deploy --token \"$FIREBASE_TOKEN\" --only hosting"
},
"keywords": [],
Expand Down
40 changes: 33 additions & 7 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
const dayOfTheWeek = (date = new Date()) => {
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const days = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];

return days[date.getDay()];
}
return days[date.getDay()];
};

const monthOfTheYear = (date = new Date()) => {
const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
return months[date.getMonth()];
};

try {
document.getElementById('day').innerText = dayOfTheWeek();
} catch(err) {}
document.getElementById("day").innerText = dayOfTheWeek();
document.getElementById("month").innerText = monthOfTheYear();
} catch (err) {}


exports.dayOfTheWeek = dayOfTheWeek;
exports.dayOfTheWeek = dayOfTheWeek;
exports.monthOfTheYear = monthOfTheYear;
16 changes: 10 additions & 6 deletions src/app.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const { dayOfTheWeek } = require('./app');
const { dayOfTheWeek } = require("./app");
const { monthOfTheYear } = require("./app");


test('getDay returns the long-format day of the week', () => {
const day = dayOfTheWeek( new Date('3/11/2020') );
expect( day ).toBe('Wednesday');
});
test("getDay returns the long-format day of the week", () => {
const day = dayOfTheWeek(new Date("3/11/2020"));
expect(day).toBe("Wednesday");
});
test("getDay returns the month of the year", () => {
const month = monthOfTheYear(new Date("3/11/2020"));
expect(month).toBe("March");
});