Coder Social home page Coder Social logo

skills-publish-packages's Introduction

Publish to GitHub Packages

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

Step 1: Create the workflow file

Welcome to "Publish packages"! 👋

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, dependencies, 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.

⌨️ 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. Navigate to the Code tab.
  3. From the main branch dropdown, click on the cd branch.
  4. Navigate to the .github/workflows/ folder, then select Add file and click on Create new file.
  5. In the Name your file... field, enter publish.yml.
  6. Add the following to the publish.yml file:
    name: Publish to Docker
    on:
      push:
        branches:
          - main
    permissions:
      packages: write
    jobs:
      publish:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout
            uses: actions/checkout@v3
          # Add your test steps here if needed...
          - name: Docker meta
            id: meta
            uses: docker/metadata-action@v4
            with:
              images: ghcr.io/YOURNAME/publish-packages/game
              tags: type=sha
          - name: Login to GHCR
            uses: docker/login-action@v2
            with:
              registry: ghcr.io
              username: ${{ github.repository_owner }}
              password: ${{ secrets.GITHUB_TOKEN }}
          - name: Build container
            uses: docker/build-push-action@v4
            with:
              context: .
              push: true
              tags: ${{ steps.meta.outputs.tags }}
  7. Replace YOURNAME with your username.
  8. Make sure that the image name is unique.
  9. Commit your changes.
  10. (optional) Create a pull request to view all the changes you'll make throughout this course. Click the Pull Requests tab, click New pull request, set base: main and compare:cd.
  11. Wait about 20 seconds then refresh this page (the one you're following instructions from). GitHub Actions will automatically update to the next step.

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

© 2023 GitHub • Code of ConductMIT License

skills-publish-packages's People

Contributors

rinats avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.