Skip to content

Commit 4d8c6f6

Browse files
authored
Continuous deployment (#5)
Created deploy script to automatically deploy new versions to GitHub packages using Docker. This resolves #2 Copied from paritytech/auto-merge-bot#16
1 parent 581a1e2 commit 4d8c6f6

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Publish package to GitHub Packages
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
env:
9+
IMAGE_NAME: action
10+
REGISTRY: ghcr.io
11+
12+
jobs:
13+
test-image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3.3.0
17+
- name: Check that the image builds
18+
run: docker build . --file Dockerfile
19+
20+
compare-versions:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
version: ${{ steps.verification.outputs.VERSION }}
24+
exists: ${{ steps.checkTag.outputs.exists }}
25+
steps:
26+
- uses: actions/checkout@v3.3.0
27+
- name: Extract package.json version
28+
id: package_version
29+
run: echo "VERSION=$(jq '.version' -r package.json)" >> $GITHUB_OUTPUT
30+
# Compare that the versions contain the same name
31+
- name: Compare versions
32+
id: verification
33+
uses: Bullrich/compare-version-on-action@main
34+
with:
35+
version: ${{ steps.package_version.outputs.VERSION }}
36+
# Verifies if there is a tag with that version number
37+
- uses: mukunku/tag-exists-action@v1.4.0
38+
if: steps.verification.outputs.VERSION
39+
id: checkTag
40+
with:
41+
tag: v${{ steps.package_version.outputs.VERSION }}
42+
43+
publish:
44+
if: github.event_name == 'push' && needs.compare-versions.outputs.exists == 'false'
45+
needs: [test-image, compare-versions]
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: write
49+
packages: write
50+
steps:
51+
- uses: actions/checkout@v3.3.0
52+
- name: Tag version and create release
53+
run: gh release create $VERSION --generate-notes
54+
env:
55+
VERSION: ${{ needs.compare-versions.outputs.version }}
56+
GH_TOKEN: ${{ github.token }}
57+
- name: Log in to the Container registry
58+
uses: docker/login-action@v3
59+
with:
60+
registry: ${{ env.REGISTRY }}
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
- name: Extract metadata (tags, labels) for Docker
64+
id: meta
65+
uses: docker/metadata-action@v5
66+
with:
67+
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
68+
tags: ${{ needs.compare-versions.outputs.version }}
69+
- uses: actions/checkout@v3
70+
- name: Build and push Docker image
71+
uses: docker/build-push-action@v5
72+
with:
73+
context: .
74+
push: true
75+
tags: ${{ steps.meta.outputs.tags }}
76+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ They are:
4545
- Example: `[{"address":"1e2345...",rank: 4, "githubHandle":"user-1"},{"address":"1e4532...",rank: 3, "githubHandle":"user-2"},{"address":"1e8335...",rank: 6}]`
4646
- `github-handles`: All the fellows handles separated by commas
4747
- Example: `user-1,user-2,user-3`
48+
49+
## Deployment
50+
51+
To deploy a new version you need to update two files:
52+
- [`package.json`](./package.json): Update the version number.
53+
- [`action.yml`](./action.yml): Update the image number in `runs.image`.
54+
**Important**: Both versions must have the same number.
55+
56+
When a commit is pushed to the main branch and the versions have changed, the system will automatically tag the commit and release a new package with such version.
57+
58+
You can find all the available versions in the [release section](./releases).

0 commit comments

Comments
 (0)