npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

publish-package-skill

v1.0.1

Published

<!-- <<< Author notes: Header of the course >>> Include a 1280×640 image, course title in sentence case, and a concise description in emphasis. In your repository settings: enable template repository, add your 1280×640 social image, auto delete head

Downloads

1

Readme

Publish to GitHub Packages

Use GitHub Actions to publish your project to a Docker image.

Welcome to "Publish packages"! :wave:

First, take a moment to examine the image below. It shows the relationship between continuous integration, continuous delivery and continuous deployment.

Continuous integration (CI) is a practice where developers integrate tested code into a shared branch several times per day. Continuous delivery (CD) is the next phase of continuous integration (CI), where we deploy our changes to the world.

Docker is an engine that allows you to run containers. Containers are packages of software that can run reliably in different environments. Containers include everything needed to run the application. Containers are lightweight in comparison to virtual machines. A dockerfile is a text document that contains all the commands and instructions necessary to build a Docker Image. A Docker image is an executable package comprised of code, dependancies, libraries, a runtime, environment variables, and configuration files. A Docker container is a runtime instance of a Docker Image.

We'll start by creating the workflow file to publish a Docker image to GitHub Packages.

:keyboard: Activity: Create the workflow file

  1. Open a new browser tab, and work on the steps in your second tab while you read the instructions in this tab.
  2. Open the pull request I made for you from the cd branch.
  3. Add a new file at .github/workflows/publish.yml.
  4. Add the following to the publish.yml file:
    name: Publish to Docker
    on:
      push:
        branches:
          - main
    jobs:
      publish:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          # Add your test steps here if needed...
          - name: Build container
            uses: docker/build-push-action@v1
            with:
              username: YOURNAME
              password: ${{ secrets.GITHUB_TOKEN }}
              registry: docker.pkg.github.com
              repository: YOURNAME/publish-packages/game
              tag_with_sha: true
  5. Replace YOURNAME with your username.
  6. Commit your changes.
  7. Wait about 20 seconds then refresh this page for the next step.

You created a publishing workflow! :tada:

We will add a Dockerfile in this pull request. The Dockerfile contains a set of instructions that get stored in a Docker Image. If you'd like, you can learn more about Dockerfiles.

:keyboard: Activity: Add a Dockerfile

  1. In the cd branch, create Dockerfile at the project root and include:
    FROM nginx:1.17
    COPY . /usr/share/nginx/html
  2. Commit your changes.
  3. Wait about 20 seconds then refresh this page for the next step.

Let's get publishing! :heart:

You can now merge your pull request!

:keyboard: Activity: Merge your pull request

  1. Click Merge pull request.
  2. Delete the branch cd (optional).
  3. Wait about 20 seconds then refresh this page for the next step.

Now things are running! :sparkles:

Whoa, now things are running! This may take a few minutes. This might take a tiny amount of time, so grab your popcorn :popcorn: and wait for the build to finish before moving on.

To pull the Docker image, we need to log into Docker first.

Before we can use this Docker image, you will need to generate a personal access token that contains the following permissions:

  • repo (all)
  • write:packages
  • read:packages

screenshot personal access token creation page with boxes for repo (all), write:packages, and read:packages checked

We will use this token to log in to Docker, and authenticate with the package.

  1. Open your terminal (Bash or Git Bash recommended)
  2. Use the following command to log in:
    docker login docker.pkg.github.com -u USERNAME -p TOKEN
  3. Replace USERNAME with your GitHub username
  4. Replace TOKEN with the Personal Access Token you just created
  5. Press Enter

If everything went well, 🤞 you should see Login Succeeded in your terminal.

:keyboard: Activity: Pull your image

  1. Copy and paste the pull command from the package instructions into your terminal. It should look something like this:
    • docker pull docker.pkg.github.com/YOURNAME/js-build/tic-tac-toe:f29 screenshot of the pull command on the GitHub package page
  2. Press Enter.
  3. You should see output indicating that the pull was successful, like Status: Downloaded newer image for docker. screenshot of successful Docker image output
  4. We can't automatically verify this step for you, so please continue on to the next step below!

Nicely done grabbing your Docker image! :relaxed:

Let's trying running it.

:keyboard: Activity: Run your image

  1. Find your image information by typing Docker image ls. screenshot of output from Docker image ls command: lists docker images, REPOSITORY TAG and docker URL
  2. Use the following command to run a container from your image:
    docker run -d -it --rm -p 8080:80 --name ttt <YOUR_IMAGE_NAME:TAG>
  3. Replace YOUR_IMAGE_NAME with your image name under the REPOSITORY column.
  4. Replace TAG with the image tag under the TAG column example of running the docker command listed above
  5. Press Enter.
  6. If everything went well, you will see hash value as output on your screen.
  7. We can't automatically verify this step for you, so please continue on to the next step below!

Congratulations friend, you've completed this course!

Here's a recap of all the tasks you've accomplished in your repository:

  • You wrote a workflow that sends a code through a continuous delivery pipeline.
  • You built a fully deployable artifact.
  • You did so using GitHub Actions and GitHub Packages!

What's next?


Get help: Post in our discussion boardReview the GitHub status page

© 2022 GitHub • Code of ConductCC-BY-4.0 License