Skip to content

Commit de48b71

Browse files
authored
Merge pull request #4 from seijinmark/dev
changes in github actions
2 parents 208e3f9 + 519ad89 commit de48b71

3 files changed

Lines changed: 254 additions & 2 deletions

File tree

.github/workflows/pr-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Thanks to https://github.com/museofficial/muse/blob/master/.github/workflows/pr-snapshot.yml for this amazing workflow.
1+
# Thanks to https://github.com/museofficial/muse/blob/master/.github/workflows/pr-release.yml for this amazing workflow.
22

33
name: Release snapshot of PR
44
on:
@@ -8,7 +8,7 @@ on:
88
- completed
99

1010
env:
11-
REGISTRY_IMAGE: ghcr.io/seijinmark/EveryoneShouldKnow
11+
REGISTRY_IMAGE: ghcr.io/seijinmark/esk
1212

1313
jobs:
1414
release-and-comment:

.github/workflows/pr-snapshot.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Thanks to https://github.com/museofficial/muse/blob/master/.github/workflows/pr-snapshot.yml for this amazing workflow.
2+
3+
name: Build snapshot of PR
4+
5+
on: pull_request
6+
7+
env:
8+
REGISTRY_IMAGE: ghcr.io/seijinmark/esk
9+
10+
jobs:
11+
build:
12+
name: Build snapshot
13+
strategy:
14+
matrix:
15+
runner-platform:
16+
- ubuntu-latest
17+
- namespace-profile-default-arm64
18+
include:
19+
- runner-platform: ubuntu-latest
20+
build-arch: linux/amd64
21+
- runner-platform: namespace-profile-default-arm64
22+
build-arch: linux/arm64
23+
runs-on: ${{ matrix.runner-platform }}
24+
steps:
25+
- name: Prepare
26+
run: |
27+
platform=${{ matrix.build-arch }}
28+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
29+
30+
- name: Docker meta
31+
id: meta
32+
uses: docker/metadata-action@v5
33+
with:
34+
images: ${{ env.REGISTRY_IMAGE }}
35+
tags: type=ref,event=pr
36+
37+
- name: Set up Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Login to GitHub Container Registry
41+
uses: docker/login-action@v3
42+
with:
43+
registry: ghcr.io
44+
username: ${{ github.repository_owner }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Get current time
48+
uses: josStorer/get-current-time@v2
49+
id: current-time
50+
51+
- name: Build
52+
id: build
53+
uses: docker/build-push-action@v6
54+
with:
55+
outputs: type=docker,dest=/tmp/image-${{ env.PLATFORM_PAIR }}.tar
56+
platforms: ${{ matrix.build-arch }}
57+
tags: |
58+
${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ env.PLATFORM_PAIR }}
59+
build-args: |
60+
COMMIT_HASH=${{ github.sha }}
61+
BUILD_DATE=${{ steps.current-time.outputs.time }}
62+
63+
- name: Export Docker meta output
64+
shell: bash
65+
run: echo $DOCKER_METADATA_OUTPUT_JSON > /tmp/metadata.json
66+
67+
- name: Upload metadata
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: metadata
71+
path: /tmp/metadata.json
72+
overwrite: true
73+
74+
- name: Export SHA
75+
run: |
76+
echo "${{ github.sha }}" > /tmp/sha.txt
77+
78+
- name: Upload SHA
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: sha
82+
path: /tmp/sha.txt
83+
overwrite: true
84+
85+
- name: Upload image
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: image-${{ env.PLATFORM_PAIR }}
89+
path: /tmp/image-${{ env.PLATFORM_PAIR }}.tar
90+
if-no-files-found: error
91+
retention-days: 1
92+
93+
- name: Save PR number in artifact
94+
shell: bash
95+
env:
96+
PR_NUMBER: ${{ github.event.number }}
97+
run: echo $PR_NUMBER > /tmp/pull_request_number.txt
98+
- name: Upload PR number
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: pull_request_number
102+
path: /tmp/pull_request_number.txt
103+
overwrite: true

.github/workflows/publish.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Thanks to https://github.com/museofficial/muse/blob/master/.github/workflows/publish.yml for this amazing workflow.
2+
3+
name: Make release & publish Docker image
4+
5+
on:
6+
push:
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
REGISTRY_IMAGE: ghcr.io/seijinmark/esk
12+
13+
jobs:
14+
publish:
15+
strategy:
16+
matrix:
17+
runner-platform:
18+
- ubuntu-latest
19+
- namespace-profile-default-arm64
20+
include:
21+
- runner-platform: ubuntu-latest
22+
build-arch: linux/amd64
23+
tagged-platform: amd64
24+
- runner-platform: namespace-profile-default-arm64
25+
build-arch: linux/arm64
26+
tagged-platform: arm64
27+
runs-on: ${{ matrix.runner-platform }}
28+
permissions:
29+
contents: read
30+
packages: write
31+
attestations: write
32+
id-token: write
33+
steps:
34+
- name: Set up Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Login to DockerHub
38+
uses: docker/login-action@v1
39+
with:
40+
username: ${{ secrets.DOCKERHUB_USERNAME }}
41+
password: ${{ secrets.DOCKERHUB_TOKEN }}
42+
43+
- name: Login to GitHub Container Registry
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.repository_owner }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Get current time
51+
uses: josStorer/get-current-time@v2
52+
id: current-time
53+
54+
- name: Build and push
55+
id: docker_build
56+
uses: docker/build-push-action@v6
57+
with:
58+
push: true
59+
tags: |
60+
seijinmark/esk:${{ github.sha }}-${{ matrix.tagged-platform }}
61+
${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ matrix.tagged-platform }}
62+
platforms: ${{ matrix.build-arch }}
63+
build-args: |
64+
COMMIT_HASH=${{ github.sha }}
65+
BUILD_DATE=${{ steps.current-time.outputs.time }}
66+
67+
combine:
68+
name: Combine platform tags
69+
runs-on: ubuntu-latest
70+
needs: publish
71+
permissions:
72+
contents: read
73+
packages: write
74+
attestations: write
75+
id-token: write
76+
steps:
77+
- uses: actions/checkout@v1
78+
79+
- name: Set up Buildx
80+
uses: docker/setup-buildx-action@v1
81+
82+
- name: Login to DockerHub
83+
uses: docker/login-action@v1
84+
with:
85+
username: ${{ secrets.DOCKERHUB_USERNAME }}
86+
password: ${{ secrets.DOCKERHUB_TOKEN }}
87+
88+
- name: Login to GitHub Container Registry
89+
uses: docker/login-action@v3
90+
with:
91+
registry: ghcr.io
92+
username: ${{ github.repository_owner }}
93+
password: ${{ secrets.GITHUB_TOKEN }}
94+
95+
- name: Get tags (Docker Hub)
96+
id: get-tags-dockerhub
97+
uses: Surgo/docker-smart-tag-action@v1
98+
with:
99+
docker_image: seijinmark/esk
100+
101+
- name: Get tags (ghcr.io)
102+
id: get-tags-ghcr
103+
uses: Surgo/docker-smart-tag-action@v1
104+
with:
105+
docker_image: ${{ env.REGISTRY_IMAGE }}
106+
107+
- name: Combine tags (Docker Hub)
108+
run: docker buildx imagetools create $(echo '${{ steps.get-tags-dockerhub.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'seijinmark/esk:${{ github.sha }}-arm64' 'seijinmark/esk:${{ github.sha }}-amd64'
109+
110+
- name: Combine tags (GitHub Container Registry)
111+
run: docker buildx imagetools create $(echo '${{ steps.get-tags-ghcr.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') '${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-arm64' '${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-amd64'
112+
113+
- name: Update Docker Hub description
114+
uses: peter-evans/dockerhub-description@v2.4.3
115+
with:
116+
username: ${{ secrets.DOCKERHUB_USERNAME }}
117+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
118+
repository: seijinmark/esk
119+
120+
release:
121+
name: Create GitHub release
122+
runs-on: ubuntu-latest
123+
needs: combine
124+
steps:
125+
- uses: actions/checkout@v2
126+
127+
- name: Get version from tag
128+
id: tag_name
129+
run: |
130+
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
131+
shell: bash
132+
133+
- name: Get Changelog Entry
134+
id: changelog_reader
135+
uses: mindsers/changelog-reader-action@v2
136+
with:
137+
version: ${{ steps.tag_name.outputs.current_version }}
138+
path: ./CHANGELOG.md
139+
140+
- name: Create/update release
141+
uses: ncipollo/release-action@v1
142+
with:
143+
tag: v${{ steps.changelog_reader.outputs.version }}
144+
name: Release v${{ steps.changelog_reader.outputs.version }}
145+
body: ${{ steps.changelog_reader.outputs.changes }}
146+
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
147+
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
148+
allowUpdates: true
149+
token: ${{ secrets.GH_PAT }}

0 commit comments

Comments
 (0)