Skip to content

shus1x/skills-publish-packages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Publish to GitHub Packages

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

Step 4: Pull your image

Now things are running! ✨

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

🧑‍🍳 While we wait for the build to finish, let's take care of a few prerequisites.

For ease of use and cross-platform compatibility (Windows, Mac, and Linux), we'll focus on Docker Desktop. Not to be confused, Docker Engine is the foundation for running containers while Docker Desktop bundles Docker Engine, a GUI, and a Virtual Machine in a single installation.

  1. Install Docker Desktop for Windows.
    • If you're using Mac or Linux, locate the correct install steps at the previous link via the lefthand tree menu.
  2. Open Docker Desktop and briefly explore.
  3. For running docker commands, access the command-line terminal either via Bash, Git Bash, Windows Command Prompt or PowerShell.

📥 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 (classic) that contains the following permissions:

Scopes for Personal Access Token (classic) 🪙

  • 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 ghcr.io -u USERNAME
  3. Replace USERNAME with your GitHub username.
  4. Enter your new Personal Access Token as the password.
  5. Press Enter.

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

⌨️ Activity: Pull your image

  1. Copy the pull command from the package instructions.
    • 🔥 Tip: To reach this page, click the Code tab at the top of your repository. Then, find the navigation bar below the repository description, and click the Packages heading link screenshot of the pull command on the GitHub package page
    • Or alternatively, in the following URL replace YOURNAME, REPONAME, and browse to https://github.com/users/YOURNAME/packages?repo_name=REPONAME and click on the package name
  2. Replace YOURNAME with your GitHub username.
  3. Replace TAG with the image tag.
  4. Paste the pull command into your terminal. It should look something like this:
    • docker pull ghcr.io/YOURNAME/publish-packages/game:TAG
  5. Press Enter.
  6. You should see output indicating that the pull was successful, like Status: Downloaded newer image for ghcr.io/YOURNAME/publish-packages/game:TAG. screenshot of successful Docker image output
  7. We can't automatically verify this step for you, so please continue on to the next step below!

Step 5: Run your image

Nicely done grabbing your Docker image! ☺️

Let's trying running it.

⌨️ 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 -dp 8080:80 --rm <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.
  5. Press Enter.
  6. If everything went well, you will see hash value as output on your screen.
  7. Optionally, you can open localhost:8080 to see the page you just created.
  8. We can't automatically verify this step for you, so please continue on to the next step below!

Finish

Congratulations friend, you've completed this course!

celebrate

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

© 2023 GitHub • Code of ConductMIT License

About

My clone repository

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published