-
Notifications
You must be signed in to change notification settings - Fork 11
140 lines (128 loc) · 4.46 KB
/
publish.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#
# SPDX-License-Identifier: Apache-2.0
#
---
name: Publish to Galaxy, GHPages, and ghcr.io
on:
create:
tags:
- "*"
workflow_dispatch:
jobs:
# Publication jobs
publish_collection:
name: Publish collection
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Install Python dependencies
run: pip install -Ur requirements.txt
- name: Build Collection
run: ansible-galaxy collection build
- name: Publish collection to Ansible Galaxy
env:
ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }}
run: |
VERSION=$(yq -r .version galaxy.yml)
ansible-galaxy collection publish --api-key ${ANSIBLE_GALAXY_API_KEY} hyperledger-fabric_ansible_collection-${VERSION}.tar.gz
- name: Set GitHub user name and email
env:
DOCS_GITHUB_NAME: ${{ secrets.DOCS_GITHUB_NAME }}
DOCS_GITHUB_EMAIL: ${{ secrets.DOCS_GITHUB_EMAIL }}
run: |
git config --local user.email ${DOCS_GITHUB_EMAIL}
git config --local user.name ${DOCS_GITHUB_NAME}
git config --local --unset-all http.${GITHUB_SERVER_URL}/.extraheader
- name: Bump version
run: .github/scripts/bump.sh
- name: Commit version bump
run: |
VERSION=$(yq -r .version galaxy.yml)
git commit -asm "Automatic version bump to ${VERSION}"
- name: Push commit to GitHub
env:
DOCS_GITHUB_NAME: ${{ secrets.DOCS_GITHUB_NAME }}
DOCS_GITHUB_ACCESS_TOKEN: ${{ secrets.DOCS_GITHUB_ACCESS_TOKEN }}
run: |
git -c http.extraheader="Authorization: Basic $(echo -n ${DOCS_GITHUB_NAME}:${DOCS_GITHUB_ACCESS_TOKEN} | base64)" push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} HEAD:main -f
publish_documentation:
name: Publish documentation
runs-on: ubuntu-latest
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Install Python dependencies
run: pip install -Ur requirements.txt
- name: Create Documentation
run: |
pushd docs
make
popd
- name: Publish documentation to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs/build # The folder the action should deploy.
# build the docker image and push to ghcr.io
# setup ready to be able to do multiarchiecture images
# https://github.com/docker/setup-qemu-action
# https://github.com/docker/setup-buildx-action
build_docker_image:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get the version number
id: version
uses: mikefarah/yq@master
with:
cmd: yq '.version' 'galaxy.yml'
- name: DEBUG echo the version
run: echo ${{steps.version.outputs.result}}
- name: Docker meta
id: ansible-beta-docker
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/hyperledger-labs/fabric-ansible
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=${{steps.version.outputs.result}}
type=sha
# in the future we should add linux/arm64 to the platforms
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.ansible-beta-docker.outputs.tags }}
labels: ${{ steps.ansible-beta-docker.outputs.labels }}