Skip to content

Commit c0719dc

Browse files
committed
build: dedup gha introduction content
Signed-off-by: David Karlsson <[email protected]>
1 parent f37633a commit c0719dc

File tree

1 file changed

+3
-169
lines changed
  • content/manuals/build/ci/github-actions

1 file changed

+3
-169
lines changed

content/manuals/build/ci/github-actions/_index.md

Lines changed: 3 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -43,172 +43,6 @@ refer to the following sections:
4343

4444
## Get started with GitHub Actions
4545

46-
{{< include "gha-tutorial.md" >}}
47-
This tutorial walks you through the process of setting up and using Docker GitHub
48-
Actions for building Docker images, and pushing images to Docker Hub. You will
49-
complete the following steps:
50-
51-
1. Create a new repository on GitHub.
52-
2. Define the GitHub Actions workflow.
53-
3. Run the workflow.
54-
55-
To follow this tutorial, you need a Docker ID and a GitHub account.
56-
57-
### Step one: Create the repository
58-
59-
Create a GitHub repository and configure the Docker Hub credentials.
60-
61-
1. Create a new GitHub repository using
62-
[this template repository](https://github.com/dvdksn/clockbox/generate).
63-
64-
The repository contains a simple Dockerfile, and nothing else. Feel free to
65-
use another repository containing a working Dockerfile if you prefer.
66-
67-
2. Open the repository **Settings**, and go to **Secrets and variables** > **Actions**.
68-
69-
3. Create a new **Repository variable** named `DOCKERHUB_USERNAME` and your Docker ID as value.
70-
71-
4. Create a new
72-
[personal access token](/security/for-developers/access-tokens/#create-an-access-token)
73-
for Docker Hub. You can name this token `clockboxci`.
74-
75-
5. Add the Docker Hub access token as a **Repository secret** in your GitHub repository, with the name
76-
`DOCKERHUB_TOKEN`.
77-
78-
With your repository created, and credentials configured, you're now ready for
79-
action.
80-
81-
### Step two: Set up the workflow
82-
83-
Set up your GitHub Actions workflow for building and pushing the image to Docker
84-
Hub.
85-
86-
1. Go to your repository on GitHub and then select the **Actions** tab.
87-
2. Select **set up a workflow yourself**.
88-
89-
This takes you to a page for creating a new GitHub actions workflow file in
90-
your repository, under `.github/workflows/main.yml` by default.
91-
92-
3. In the editor window, copy and paste the following YAML configuration.
93-
94-
```yaml
95-
name: ci
96-
97-
on:
98-
push:
99-
branches:
100-
- "main"
101-
102-
jobs:
103-
build:
104-
runs-on: ubuntu-latest
105-
```
106-
107-
- `name`: the name of this workflow.
108-
- `on.push.branches`: specifies that this workflow should run on every push
109-
event for the branches in the list.
110-
- `jobs`: creates a job ID (`build`) and declares the type of machine that
111-
the job should run on.
112-
113-
For more information about the YAML syntax used here, see
114-
[Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).
115-
116-
### Step three: Define the workflow steps
117-
118-
Now the essentials: what steps to run, and in what order to run them.
119-
120-
```yaml
121-
jobs:
122-
build:
123-
runs-on: ubuntu-latest
124-
steps:
125-
- name: Login to Docker Hub
126-
uses: docker/login-action@v3
127-
with:
128-
username: ${{ vars.DOCKERHUB_USERNAME }}
129-
password: ${{ secrets.DOCKERHUB_TOKEN }}
130-
131-
- name: Set up Docker Buildx
132-
uses: docker/setup-buildx-action@v3
133-
134-
- name: Build and push
135-
uses: docker/build-push-action@v6
136-
with:
137-
push: true
138-
tags: ${{ vars.DOCKERHUB_USERNAME }}/clockbox:latest
139-
```
140-
141-
The previous YAML snippet contains a sequence of steps that:
142-
143-
1. Signs in to Docker Hub, using the
144-
[Docker Login](https://github.com/marketplace/actions/docker-login) action and your Docker Hub credentials.
145-
2. Creates a BuildKit builder instance using the
146-
[Docker Setup Buildx](https://github.com/marketplace/actions/docker-setup-buildx) action.
147-
3. Builds the container image and pushes it to the Docker Hub repository, using
148-
[Build and push Docker images](https://github.com/marketplace/actions/build-and-push-docker-images).
149-
150-
The `with` key lists a number of input parameters that configures the step:
151-
152-
- `push`: tells the action to upload the image to a registry after building
153-
it.
154-
- `tags`: tags that specify where to push the image.
155-
156-
Add these steps to your workflow file. The full workflow configuration should
157-
look as follows:
158-
159-
160-
```yaml
161-
name: ci
162-
163-
on:
164-
push:
165-
branches:
166-
- "main"
167-
168-
jobs:
169-
build:
170-
runs-on: ubuntu-latest
171-
steps:
172-
- name: Login to Docker Hub
173-
uses: docker/login-action@v3
174-
with:
175-
username: ${{ vars.DOCKERHUB_USERNAME }}
176-
password: ${{ secrets.DOCKERHUB_TOKEN }}
177-
178-
- name: Set up Docker Buildx
179-
uses: docker/setup-buildx-action@v3
180-
181-
- name: Build and push
182-
uses: docker/build-push-action@v6
183-
with:
184-
push: true
185-
tags: ${{ vars.DOCKERHUB_USERNAME }}/clockbox:latest
186-
```
187-
188-
### Run the workflow
189-
190-
Save the workflow file and run the job.
191-
192-
1. Select **Commit changes...** and push the changes to the `main` branch.
193-
194-
After pushing the commit, the workflow starts automatically.
195-
196-
2. Go to the **Actions** tab. It displays the workflow.
197-
198-
Selecting the workflow shows you the breakdown of all the steps.
199-
200-
3. When the workflow is complete, go to your
201-
[repositories on Docker Hub](https://hub.docker.com/repositories).
202-
203-
If you see the new repository in that list, it means the GitHub Actions
204-
successfully pushed the image to Docker Hub.
205-
206-
## Next steps
207-
208-
This tutorial has shown you how to create a simple GitHub Actions workflow,
209-
using the official Docker actions, to build and push an image to Docker Hub.
210-
211-
There are many more things you can do to customize your workflow to better suit
212-
your needs. To learn more about some of the more advanced use cases, take a look
213-
at the advanced examples, such as [building multi-platform images](multi-platform.md),
214-
or [using cache storage backends](cache.md) and also how to [configure your builder](configure-builder.md).
46+
The [Introduction to GitHub Actions with Docker](/guides/gha.md) guide walks
47+
you through the process of setting up and using Docker GitHub Actions for
48+
building Docker images, and pushing images to Docker Hub.

0 commit comments

Comments
 (0)