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

Rails guide upgrade (part 2) #22114

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Renamed tutorial sections
  • Loading branch information
igor-alexandrov committed Feb 25, 2025
commit 54dc285580e3a6e8402662c0c8ca8fc19a6ba79b
72 changes: 9 additions & 63 deletions content/guides/ruby/configure-github-actions.md
Original file line number Diff line number Diff line change
@@ -14,81 +14,27 @@ aliases:

Complete all the previous sections of this guide, starting with [Containerize a Ruby on Rails application](containerize.md). You must have a [GitHub](https://github.com/signup) account and a [Docker](https://hub.docker.com/signup) account to complete this section.

If you didn't create a GitHub repository for your project yet, it is time to do it. You also need to configure Docker Hub credentials, make a commit and push the source code.
If you didn't create a [GitHub repository](https://github.com/new) for your project yet, it is time to do it. After creating the repository, don't forget to [add a remote](https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories) and ensure you can commit and [push your code](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository#about-git-push) to GitHub.

1. [Create a new repository](https://github.com/new) on GitHub.
1. In your project's GitHub repository, open **Settings**, and go to **Secrets and variables** > **Actions**.

2. Open the repository **Settings**, and go to **Secrets and variables** >
**Actions**.
2. Under the `Variables` tab, create a new **Repository variable** named `DOCKER_USERNAME` and your Docker ID as a value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Under the `Variables` tab, create a new **Repository variable** named `DOCKER_USERNAME` and your Docker ID as a value.
2. Under the **Variables** tab, create a new **Repository variable** named `DOCKER_USERNAME` and your Docker ID as a value.


3. Under the `Variables` tab, create a new **Repository variable** named `DOCKER_USERNAME` and your Docker ID as a value.
3. Create a new [Personal Access Token (PAT)](/manuals/security/for-developers/access-tokens.md#create-an-access-token) for Docker Hub. You can name this token `docker-tutorial`. Make sure access permissions include Read and Write.

4. Create a new [Personal Access Token (PAT)](/manuals/security/for-developers/access-tokens.md#create-an-access-token) for Docker Hub. You can name this token `docker-tutorial`. Make sure access permissions include Read and Write.

5. Add the PAT as a **Repository secret** in your GitHub repository, with the name
4. Add the PAT as a **Repository secret** in your GitHub repository, with the name
`DOCKERHUB_TOKEN`.

6. In your local repository on your machine, run the following command to change
the origin to the repository you just created. Make sure you change
`your-username` to your GitHub username and `your-repository` to the name of
the repository you created.

```console
$ git remote set-url origin https://github.com/your-username/your-repository.git
```

7. Run the following commands to stage, commit, and push your local repository to GitHub.

```console
$ git add -A
$ git commit -m "my commit"
$ git push -u origin main


## Overview

GitHub Actions is a CI/CD (Continuous Integration and Continuous Deployment) automation tool built into GitHub. It allows you to define custom workflows for building, testing, and deploying your code when specific events occur (e.g., pushing code, creating a pull request, etc.). A workflow is a YAML-based automation script that defines a sequence of steps to be executed when triggered. Workflows are stored in the `.github/workflows/` directory of a repository.

In this section, you'll learn how to set up and use GitHub Actions to build your Docker image as well as push it to Docker Hub. You will complete the following steps:

1. Create a new repository on GitHub.
2. Define the GitHub Actions workflow.
3. Run the workflow.

## 1. Create the repository

If you didn't create the repository for your project yet, it is time to do it. You also need to configure Docker Hub credentials, make a commit and push the source code.

1. [Create a new repository](https://github.com/new) on GitHub.

2. Open the repository **Settings**, and go to **Secrets and variables** >
**Actions**.

3. Create a new **Repository variable** named `DOCKER_USERNAME` and your Docker ID as value.

4. Create a new [Personal Access Token (PAT)](/manuals/security/for-developers/access-tokens.md#create-an-access-token) for Docker Hub. You can name this token `docker-tutorial`. Make sure access permissions include Read and Write.

5. Add the PAT as a **Repository secret** in your GitHub repository, with the name
`DOCKERHUB_TOKEN`.

6. In your local repository on your machine, run the following command to change
the origin to the repository you just created. Make sure you change
`your-username` to your GitHub username and `your-repository` to the name of
the repository you created.

```console
$ git remote set-url origin https://github.com/your-username/your-repository.git
```

7. Run the following commands to stage, commit, and push your local repository to GitHub.

```console
$ git add -A
$ git commit -m "my commit"
$ git push -u origin main
```
1. Define the GitHub Actions workflow.
2. Run the workflow.

## 2. Set up the workflow
## 1. Set up the workflow

Set up your GitHub Actions workflow for building, testing, and pushing the image
to Docker Hub.
@@ -133,7 +79,7 @@ to Docker Hub.
For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).

## 3. Run the workflow
## 2. Run the workflow

Save the workflow file and run the job.