generated from actions/hello-world-docker-action
-
Notifications
You must be signed in to change notification settings - Fork 2
45 lines (39 loc) · 1.19 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: build Docker Image
on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Show Version
run: |
echo "VERSION=$(cat VERSION)" >> "$GITHUB_ENV"
- name: Build the Docker image
run: |
docker build -t ${{ github.repository }}:"$VERSION" .
docker build -t ghcr.io/${{ github.repository }}:"$VERSION" .
- name: Publish to Docker Hub
run: |
printenv PASSWORD | docker login -u "$USERNAME" --password-stdin
docker push ${{ github.repository }}:"$VERSION"
docker logout
env:
USERNAME: ${{ secrets.username }}
PASSWORD: ${{ secrets.password }}
- name: Publish to GitHub Container Registry
run: |
printenv PASSWORD | docker login ghcr.io --username "$USERNAME" --password-stdin
docker push ghcr.io/${{ github.repository }}:"$VERSION"
docker logout ghcr.io
env:
USERNAME: ${{ github.repository_owner }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}