File tree Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Build and push Docker image with custom tag
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ tag :
7
+ description : ' Tag for the Docker image'
8
+ required : true
9
+ default : ' latest'
10
+
11
+ permissions :
12
+ packages : write
13
+
14
+ jobs :
15
+ push_to_ghcr :
16
+ runs-on : ubuntu-latest
17
+ steps :
18
+ - name : Checkout GitHub Action
19
+ uses : actions/checkout@v4
20
+
21
+ - name : Login to GitHub Container Registry
22
+ uses : docker/login-action@v3
23
+ with :
24
+ registry : ghcr.io
25
+ username : ${{ github.actor }}
26
+ password : ${{ secrets.GITHUB_TOKEN }}
27
+
28
+ - name : Build and Push Docker Image
29
+ run : |
30
+ GITHUB_REPO="${GITHUB_REPO,,}" # convert repo name to lowercase as required by docker
31
+ TAG=${{ github.event.inputs.tag }}
32
+ echo "building docker image in repository '$GITHUB_REPO' with tag '$TAG' ..."
33
+ docker build --label "org.opencontainers.image.title=copilot-metrics-viewer" --label "org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage" --label "org.opencontainers.image.source=$GITHUB_REPO" -t ghcr.io/$GITHUB_REPO:$TAG .
34
+ docker push ghcr.io/$GITHUB_REPO:$TAG
35
+ env :
36
+ GITHUB_REPO : ${{ github.repository }}
Original file line number Diff line number Diff line change
1
+ name : Build and push Docker image with release tag
2
+
3
+ on :
4
+
5
+ release :
6
+ types :
7
+ - published
8
+
9
+ # Allows you to run this workflow manually from the Actions tab
10
+ workflow_dispatch :
11
+
12
+ permissions :
13
+ packages : write
14
+
15
+ jobs :
16
+ push_to_ghcr :
17
+ runs-on : ubuntu-latest
18
+ steps :
19
+ - name : Checkout GitHub Action
20
+ uses : actions/checkout@v4
21
+
22
+ - name : Get Latest Release Tag
23
+ id : get_latest_release
24
+ uses : actions/github-script@v6
25
+ with :
26
+ script : |
27
+ const latestRelease = await github.repos.getLatestRelease({
28
+ owner: context.repo.owner,
29
+ repo: context.repo.repo,
30
+ });
31
+ return latestRelease.data.tag_name;
32
+
33
+ - name : Login to GitHub Container Registry
34
+ uses : docker/login-action@v3
35
+ with :
36
+ registry : ghcr.io
37
+ username : ${{ github.actor }}
38
+ password : ${{ secrets.GITHUB_TOKEN }}
39
+
40
+ - name : Build and Push Docker Image
41
+ run : |
42
+ GITHUB_REPO="${GITHUB_REPO,,}" # convert repo name to lowercase as required by docker
43
+ TAG=${{ steps.get_latest_release.outputs.result }}
44
+ echo "building docker image in repository '$GITHUB_REPO' with tag '$TAG' ..."
45
+ docker build --label "org.opencontainers.image.title=copilot-metrics-viewer" --label "org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage" --label "org.opencontainers.image.source=$GITHUB_REPO" -t ghcr.io/$GITHUB_REPO:$TAG .
46
+ docker push ghcr.io/$GITHUB_REPO:$TAG
47
+ env :
48
+ GITHUB_REPO : ${{ github.repository }}
You can’t perform that action at this time.
0 commit comments