Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment test #523

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0980121
Update README.md
LilachD Nov 14, 2023
943e05b
update models and PostController.create with matching test updates
LilachD Nov 14, 2023
7966768
Merge pull request #1 from LilachD/add-username-to-user-model
LilachD Nov 14, 2023
f95619c
Create node.js.yml
LilachD Nov 15, 2023
6d7445d
add mongodb action
LilachD Nov 15, 2023
b713e9b
add cypress action
LilachD Nov 15, 2023
455d02c
update npm start command to start:test
LilachD Nov 15, 2023
cbf609f
update npm start:test command to npm run start:test
LilachD Nov 15, 2023
da649d4
Merge pull request #3 from LilachD/testing-workflow-1
LilachD Nov 15, 2023
bd1c862
update workflow file name
LilachD Nov 15, 2023
761a501
update homepage title
LilachD Nov 15, 2023
2687059
fix homepage title
LilachD Nov 15, 2023
507f9e9
Merge pull request #4 from LilachD/testing-workflow
LilachD Nov 15, 2023
c61a598
separate build and test jobs
LilachD Nov 15, 2023
469d30b
undo build and test separation
LilachD Nov 15, 2023
1879793
add deploy workflow file"
LilachD Nov 15, 2023
c9a6c81
update deploy.yml
LilachD Nov 16, 2023
067d5fc
Merge pull request #5 from LilachD/deploy-workflow
LilachD Nov 16, 2023
772fdb1
adding pr.merged == false condition for build and test ci
LilachD Nov 16, 2023
5d40219
Merge pull request #6 from LilachD/deploy-workflow
LilachD Nov 16, 2023
e47d71e
update test workflow if statement and deploy workflow workflow_run
LilachD Nov 16, 2023
541ca01
Merge pull request #7 from LilachD/deploy-workflow
LilachD Nov 16, 2023
7528cf1
remove push to main trigger on test workflow
LilachD Nov 16, 2023
e2fcf54
Merge pull request #8 from LilachD/deploy-workflow
LilachD Nov 16, 2023
9e5580b
update if statement in test workflow
LilachD Nov 16, 2023
9ff6f6a
Merge pull request #9 from LilachD/deploy-workflow
LilachD Nov 16, 2023
bb1d237
update if statement in test workflow
LilachD Nov 16, 2023
cfa49e8
Merge pull request #10 from LilachD/deploy-workflow
LilachD Nov 16, 2023
7882973
small change to echo command in deploy.yml for testing purposes
LilachD Nov 16, 2023
64b0918
change deploy trigger to push to main
LilachD Nov 16, 2023
e72b188
Merge pull request #11 from LilachD/deploy-workflow
LilachD Nov 16, 2023
e5134f5
change deploy workflow echo command
LilachD Nov 16, 2023
48b583e
change deploy workflow echo command
LilachD Nov 16, 2023
7005277
deployment test
Bereketmebrahtu Nov 16, 2023
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
43 changes: 43 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Test

on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request' && github.event.action == 'opened' ||
github.event_name == 'push' && github.event.ref == 'refs/heads/main' &&
github.event.before == github.sha

strategy:
matrix:
node-version: [18.x]
mongodb-version: ['6.0']

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Cypress run
uses: cypress-io/github-action@v6
with:
build: npm run build --if-present
start: npm run start:test
wait-on: http://localhost:3030


25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy to AWS S3

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

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

- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2 # Specify your AWS region

- name: Upload to S3
run: |
aws s3 sync ./your-app s3://b-l-acebook-bucket
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It uses:

## Card wall

REPLACE THIS TEXT WITH A LINK TO YOUR CARD WALL
https://trello.com/b/LTthkPOI/acebook-bl

## Quickstart

Expand Down
2 changes: 1 addition & 1 deletion bin/www
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
/* eslint-disable no-process-exit */

/**
* Module dependencies.
Expand Down
4 changes: 3 additions & 1 deletion controllers/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const PostsController = {
res.render("posts/new", {});
},
Create: (req, res) => {
const post = new Post(req.body);
const message = req.body.message;
const author = req.session.user.username;
const post = new Post({message, author});
post.save((err) => {
if (err) {
throw err;
Expand Down
3 changes: 2 additions & 1 deletion controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ const User = require("../models/user");

const UsersController = {
New: (req, res) => {
res.render("users/new", {});
res.render("users/new", { title: "Acebook" });
},

Create: (req, res) => {
const user = new User(req.body);
console.log('user:', user)
user.save((err) => {
if (err) {
throw err;
Expand Down
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
video: true,
e2e: {
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/user_can_see_posts_count_on_post.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ describe("Timeline", () => {
it("can see likes count on a new post", () => {
// sign up
cy.visit("/users/new");
cy.get("#username").type("someone");
cy.get("#email").type("someone@example.com");
cy.get("#password").type("password");
cy.get("#submit").click();
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/user_can_sign_in.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ describe("Authentication", () => {
it("A user signs in and is redirected to /posts", () => {
// sign up
cy.visit("/users/new");
cy.get("#username").type("someone");
cy.get("#email").type("someone@example.com");
cy.get("#password").type("password");
cy.get("#submit").click();
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/user_can_sign_up.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ describe("Registration", () => {
it("A user signs up and is redirected to sign in", () => {
// sign up
cy.visit("/users/new");
cy.get("#username").type("someone");
cy.get("#email").type("someone@example.com");
cy.get("#password").type("password");
cy.get("#submit").click();
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/user_can_submit_posts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ describe("Timeline", () => {
it("can submit posts, when signed in, and view them", () => {
// sign up
cy.visit("/users/new");
cy.get("#username").type("someone");
cy.get("#email").type("someone@example.com");
cy.get("#password").type("password");
cy.get("#submit").click();
Expand Down
1 change: 1 addition & 0 deletions models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const mongoose = require("mongoose");

const PostSchema = new mongoose.Schema({
message: String,
author: String,
likes: { type: Number, default: 0 }
});

Expand Down
1 change: 1 addition & 0 deletions models/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema({
username: String,
email: String,
password: String,
});
Expand Down
Loading