-
Notifications
You must be signed in to change notification settings - Fork 190
99 lines (84 loc) · 2.95 KB
/
Copy pathpublish-docker.yml
File metadata and controls
99 lines (84 loc) · 2.95 KB
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
name: Publish to GHCR
on:
workflow_run:
workflows: [Release]
types:
- completed
workflow_dispatch:
inputs:
tag:
type: string
description: Release tag to containerize
required: true
env:
REGISTRY: ghcr.io
IMAGE_BASE_TAG: ghcr.io/${{ github.repository }}
ARTIFACT_TAG: x86_64-unknown-linux-musl
permissions:
actions: read
contents: read
packages: write
jobs:
containerize-release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: docker-binary-artifact-${{ env.ARTIFACT_TAG }}
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Download version artifact
uses: actions/download-artifact@v4
with:
name: docker-tag-artifact
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Retreive version from artifact
run: |
TEMP_VERSION=$(cat cli-version.txt | tr -d ' \r\n' | sed 's/^[^0-9]*//')
test -z $TEMP_VERSION && exit 1
echo "CLI_VERSION=$TEMP_VERSION" >> $GITHUB_ENV
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.IMAGE_BASE_TAG }}:${{ env.CLI_VERSION }}, ${{ env.IMAGE_BASE_TAG }}:latest
containerize-manual:
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract CLI version from tag
run: echo "CLI_VERSION=$(echo '${{ github.event.inputs.tag }}' | tr -d ' \r\n' | sed 's/^[^0-9]*//')" >> $GITHUB_ENV
- name: Download release binary
run: |
wget --header='Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
https://github.com/${{ github.repository }}/releases/download/v${{ env.CLI_VERSION }}/railway-v${{ env.CLI_VERSION }}-x86_64-unknown-linux-musl.tar.gz -O - | tar xvfz -
- name: Test run the binary
run: ./railway --version
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.IMAGE_BASE_TAG }}:${{ env.CLI_VERSION }}, ${{ env.IMAGE_BASE_TAG }}:latest