-
Notifications
You must be signed in to change notification settings - Fork 3
69 lines (64 loc) · 1.98 KB
/
docker-image.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: CI/CD
on:
push:
branches:
- "**"
tags:
- 'v*.*.*'
pull_request:
branches:
- "master"
env:
IMAGE_NAME: ingv/fdsnws-fetcher
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build docker image
run: |
IMAGE_TAG=${GITHUB_REF#refs/tags/v}
docker build --no-cache --pull --tag ${{ env.IMAGE_NAME }}:latest .
- name: Archive Docker image
run: |
docker save -o image.tar ${{ env.IMAGE_NAME }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: |
./image.tar
./README.md
publish-tag-and-latest:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: docker-image
- name: Load archived Docker image
run: docker load -i image.tar
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Push Docker Image to Docker Hub
run: |
IMAGE_TAG=${GITHUB_REF#refs/tags/v}
docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:$IMAGE_TAG
docker push ${{ env.IMAGE_NAME }}:latest
docker push ${{ env.IMAGE_NAME }}:$IMAGE_TAG
- name: Publish Docker description (README.md) to Docker Hub
run: |
wget -O docker-pushrm "https://github.com/christian-korneck/docker-pushrm/releases/download/v1.7.0/docker-pushrm_linux_amd64"
chmod +x docker-pushrm
./docker-pushrm --file README.md ${{ env.IMAGE_NAME }}
test-publiccode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate publiccode file
run: |
docker run -i --rm italia/publiccode-parser-go /dev/stdin < publiccode.yml