{"id":17980000,"url":"https://github.com/peckjon/pets-walkthrough","last_synced_at":"2025-04-04T01:13:38.351Z","repository":{"id":106832271,"uuid":"575562563","full_name":"peckjon/pets-walkthrough","owner":"peckjon","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-09T08:52:03.000Z","size":600,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T12:44:18.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peckjon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-07T19:46:46.000Z","updated_at":"2024-06-12T14:53:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d1564f5-d997-4ac5-a35b-69d2effa24de","html_url":"https://github.com/peckjon/pets-walkthrough","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"GeekTrainer/pets-walkthrough","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peckjon%2Fpets-walkthrough","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peckjon%2Fpets-walkthrough/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peckjon%2Fpets-walkthrough/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peckjon%2Fpets-walkthrough/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peckjon","download_url":"https://codeload.github.com/peckjon/pets-walkthrough/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103307,"owners_count":20884023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T17:40:43.534Z","updated_at":"2025-04-04T01:13:38.336Z","avatar_url":"https://github.com/peckjon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample Next.js app with MongoDB\n\nThis repository contains a sample app generated from the [Next.js example using MongoDB](https://github.com/vercel/next.js/tree/canary/examples/with-mongodb). The design is to be used as a walk-through of GitHub features, including [Codespaces](https://github.com/features/codespaces), [Actions](https://github.com/features/actions) and [GitHub Advanced Security (GHAS)](https://github.com/features/security).\n\n## Structure of the repository\n\nThe repository is configured with a [dev container](https://code.visualstudio.com/docs/remote/create-dev-container) which can be used with Codespaces. The container uses Docker Compose to combine the [Cypress](https://github.com/cypress-io/cypress-docker-images) image for web app dev and [MongoDB](https://www.mongodb.com/compatibility/docker) for the database.\n\n## Running the in Codespaces\n\n1. In the upper-right corner of the main page for the repository, select **Code** \u003e **Codespaces** \u003e **Create codespace on main**.\n2. After the codespace is loaded, open a new terminal by selecting **Ctl** **`** on your keyboard.\n3. Enter the following commands to start the dev server\n\n   ```bash\n   npm install\n   npm run dev\n   ```\n\n\u003e **IMPORTANT** To successfully launch the server, an [environment variable](settings/secrets/codespaces) must be created for the Codespace.\n\n## Dog images\n\nYou can use the following URLs for the images for pets created in the app:\n\n- https://raw.githubusercontent.com/GeekTrainer/pets-walkthrough/main/pics/roscoe.jpg\n- https://raw.githubusercontent.com/GeekTrainer/pets-walkthrough/main/pics/sammy.jpg\n- https://raw.githubusercontent.com/GeekTrainer/pets-walkthrough/main/pics/sushi.jpg\n\n## Code snippets\n\n### Testing action\n\n```yml\nname: End-to-end tests\non:\n  push:\n    branches: [\"main\"]\n  pull_request:\n    branches: [\"main\"]\njobs:\n  cypress-run:\n    runs-on: ubuntu-20.04\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n      # Install NPM dependencies, cache them correctly\n      # and run all Cypress tests\n      - name: Cypress run\n        uses: cypress-io/github-action@v4\n        with:\n          build: npm run build\n          start: npm run start\n        env:\n          MONGODB_URI: ${{ secrets.MONGODB_URI }}\n```\n\n## Custom action\n\n### package.json\n\n```json\n{\n  \"dependencies\": {\n    \"@actions/core\": \"^1.9.1\",\n    \"@actions/github\": \"^5.0.3\"\n  },\n  \"devDependencies\": {\n    \"@vercel/ncc\": \"^0.34.0\"\n  },\n  \"scripts\": {\n    \"build\": \"ncc build index.js --license licenses.txt\"\n  }\n}\n```\n\n### Logic index.js\n\n```javascript\nconst core = require(\"@actions/core\");\nconst github = require(\"@actions/github\");\n\nasync function run() {\n  try {\n    // get GitHub token\n    const token = core.getInput(\"repo-token\", { required: true });\n    const octokit = github.getOctokit(token);\n    const { context } = github;\n\n    // get the current pr\n    const pr = context.payload.pull_request;\n    console.log(pr.title);\n    \n    // create an issue for pr\n    console.log(\"Creating issue for PR\");\n    const issue = await octokit.rest.issues.create({\n      owner: context.repo.owner,\n      repo: context.repo.repo,\n      title: pr.title,\n      body: pr.body,\n    });\n    // add comment to PR\n    console.log(\"Adding comment to PR\");\n    await octokit.rest.issues.createComment({\n      owner: context.repo.owner,\n      repo: context.repo.repo,\n      issue_number: pr.number,\n      body: `Issue created: ${issue.data.html_url}`,\n    });\n  } catch (error) {\n    core.setFailed(error.message);\n  }\n}\n\nrun();\n```\n\n### action.yml\n\n```yml\nname: 'Create issue'\ndescription: 'Greet someone and record the time'\ninputs:\n  repo-token:\n    description: 'GitHub Token'\n    required: true\nruns:\n  using: 'node16'\n  main: 'dist/index.js'\n```\n\n### .gitignore\n\n```bash\nnode_modules\n```\n\n### Script to build and deploy\n\n```bash\nnpm run build\ngit add .\ngit commit -m \"Initial commit\"\ngit tag -a -m \"My first action release\" v1.0\ngit push --follow-tags\n```\n\n## Use the workflow\n\n```yml\non: [pull_request]\n\njobs:\n  create_issue:\n    runs-on: ubuntu-latest\n    name: Create issue\n    steps:\n      # To use this repository's private action,\n      # you must check out the repository\n      - name: Checkout\n        uses: actions/checkout@v3\n      - name: Create issue\n        uses: \u003cYOUR_HANDLE\u003e/\u003cYOUR_REPOSITORY\u003e@v1.0 # Uses an action in the root directory\n        id: create-issue\n        with:\n          repo-token: ${{ secrets.GITHUB_TOKEN }}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeckjon%2Fpets-walkthrough","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeckjon%2Fpets-walkthrough","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeckjon%2Fpets-walkthrough/lists"}