Skip to content

Commit 3249e6d

Browse files
authored
Merge pull request #139 from github-copilot-resources/feature/tagging-images
Feature/tagging images - fixes #130 #66
2 parents a5cfc56 + ff18d0e commit 3249e6d

File tree

10 files changed

+262
-82
lines changed

10 files changed

+262
-82
lines changed

.github/workflows/deploy_proxy_to_ghcr.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/deploy_to_ghcr.yml

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,73 @@ jobs:
2525
username: ${{ github.actor }}
2626
password: ${{ secrets.GITHUB_TOKEN }}
2727

28-
- name: Build and Push Docker Image
29-
run: |
30-
GITHUB_REPO="${GITHUB_REPO,,}" # convert repo name to lowercase as required by docker
31-
echo "building docker image in repository '$GITHUB_REPO' ..."
32-
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:latest .
33-
docker push ghcr.io/$GITHUB_REPO:latest
34-
env:
35-
GITHUB_REPO: ${{ github.repository }}
28+
# Adding below tag any push to main as "latest"
29+
# To deploy latest, create a release with a semver tag
30+
# type=raw,value=latest,enable={{is_default_branch}}
31+
- name: Extract metadata
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/${{ github.repository }}
36+
labels: |
37+
org.opencontainers.image.title=copilot-metrics-viewer
38+
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
39+
org.opencontainers.image.source=${{ github.repository }}
40+
tags: |
41+
type=sha
42+
type=ref,event=branch
43+
type=ref,event=pr
44+
type=semver,pattern={{version}}
45+
type=semver,pattern={{major}}.{{minor}}
46+
47+
- name: Build and push
48+
uses: docker/build-push-action@v5
49+
with:
50+
context: .
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
push: true
54+
55+
push_proxy_to_ghcr:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout GitHub Action
59+
uses: actions/checkout@v4
60+
61+
- name: Login to GitHub Container Registry
62+
uses: docker/login-action@v3
63+
with:
64+
registry: ghcr.io
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
# Adding below tag any push to main as "latest"
69+
# To deploy latest, create a release with a semver tag
70+
# type=raw,value=latest,enable={{is_default_branch}}
71+
- name: Extract metadata
72+
id: meta
73+
uses: docker/metadata-action@v5
74+
with:
75+
images: ghcr.io/${{ github.repository }}-with-proxy
76+
labels: |
77+
org.opencontainers.image.title=copilot-metrics-viewer-with-proxy
78+
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
79+
org.opencontainers.image.source=${{ github.repository }}
80+
tags: |
81+
type=sha
82+
type=ref,event=branch
83+
type=ref,event=pr
84+
type=semver,pattern={{version}}
85+
type=semver,pattern={{major}}.{{minor}}
86+
87+
- name: Build and push api
88+
uses: docker/build-push-action@v5
89+
with:
90+
context: .
91+
file: api.Dockerfile
92+
tags: ${{ steps.meta.outputs.tags }}
93+
labels: ${{ steps.meta.outputs.labels }}
94+
push: true
3695

3796
deploy:
3897
runs-on: ubuntu-latest
@@ -49,4 +108,4 @@ jobs:
49108
app-name: 'copilot-metrics-viewer'
50109
slot-name: 'production'
51110
publish-profile: ${{ secrets.AzureAppService_PublishProfile_e94dfd38811a421eafe5ce4eee13b68b }}
52-
images: 'ghcr.io/github-copilot-resources/copilot-metrics-viewer:latest'
111+
images: 'ghcr.io/github-copilot-resources/copilot-metrics-viewer:main'
Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Build and push Docker image with custom tag
2+
# NOTE: this pipeline is not needed as images are pushed after release
23

34
on:
45
workflow_dispatch:
56
inputs:
67
tag:
7-
description: 'Tag for the Docker image'
8+
description: 'existing git tag to be used as tag for the Docker image e.g. "custom-tag"'
89
required: true
9-
default: 'latest'
10+
default: 'my-tag'
1011

1112
permissions:
1213
packages: write
@@ -19,9 +20,49 @@ jobs:
1920
uses: actions/checkout@v4
2021
with:
2122
fetch-depth: 0 # Fetch all history for all tags and branches
23+
ref: ${{ github.event.inputs.tag }}
24+
25+
- name: Login to GitHub Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ghcr.io/${{ github.repository }}
37+
labels: |
38+
org.opencontainers.image.title=copilot-metrics-viewer
39+
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
40+
org.opencontainers.image.source=${{ github.repository }}
41+
tags: |
42+
type=raw,enable=true,priority=1,value=${{ github.event.inputs.tag }}
43+
type=sha
44+
type=ref,event=branch
45+
type=ref,event=pr
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{major}}.{{minor}}
48+
49+
- name: Build and push
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: .
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
push: true
56+
57+
push_proxy_to_ghcr:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout GitHub Action
61+
uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 0 # Fetch all history for all tags and branches
64+
ref: ${{ github.event.inputs.tag }}
2265

23-
- name: Checkout specific tag
24-
run: git checkout tags/v${{ github.event.inputs.tag }}
2566

2667
- name: Login to GitHub Container Registry
2768
uses: docker/login-action@v3
@@ -30,12 +71,29 @@ jobs:
3071
username: ${{ github.actor }}
3172
password: ${{ secrets.GITHUB_TOKEN }}
3273

33-
- name: Build and Push Docker Image
34-
run: |
35-
GITHUB_REPO="${GITHUB_REPO,,}" # convert repo name to lowercase as required by docker
36-
TAG=${{ github.event.inputs.tag }}
37-
echo "building docker image in repository '$GITHUB_REPO' with tag '$TAG' ..."
38-
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 .
39-
docker push ghcr.io/$GITHUB_REPO:$TAG
40-
env:
41-
GITHUB_REPO: ${{ github.repository }}
74+
- name: Extract metadata
75+
id: meta
76+
uses: docker/metadata-action@v5
77+
with:
78+
images: ghcr.io/${{ github.repository }}-with-proxy
79+
labels: |
80+
org.opencontainers.image.title=copilot-metrics-viewer-with-proxy
81+
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
82+
org.opencontainers.image.source=${{ github.repository }}
83+
tags: |
84+
type=raw,enable=true,priority=1,value=${{ github.event.inputs.tag }}
85+
type=sha
86+
type=ref,event=branch
87+
type=ref,event=pr
88+
type=semver,pattern={{version}}
89+
type=semver,pattern={{major}}.{{minor}}
90+
91+
- name: Build and push api
92+
uses: docker/build-push-action@v5
93+
with:
94+
context: .
95+
file: api.Dockerfile
96+
tags: ${{ steps.meta.outputs.tags }}
97+
labels: ${{ steps.meta.outputs.labels }}
98+
push: true
99+

.github/workflows/deploy_to_ghcr_tag_release.yaml

Lines changed: 87 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,107 @@ on:
1111

1212
permissions:
1313
packages: write
14+
contents: write
1415

1516
jobs:
17+
version_update:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout GitHub Action
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- uses: actions4git/setup-git@v1
26+
27+
- name: Update version in package.json
28+
id: version
29+
run: |
30+
git checkout -b temp-version-update
31+
version=$(npm version from-git --no-git-tag-version)
32+
cd api
33+
npm version from-git --no-git-tag-version
34+
git add package.json
35+
git commit --signoff --message $version
36+
git checkout main
37+
git merge temp-version-update
38+
git tag --force $version
39+
git push origin main -f --tags
40+
1641
push_to_ghcr:
1742
runs-on: ubuntu-latest
43+
needs: version_update
1844
steps:
1945
- name: Checkout GitHub Action
2046
uses: actions/checkout@v4
2147

22-
- name: Get Latest Release Tag
23-
id: get_latest_release
24-
uses: actions/github-script@v6
48+
- name: Login to GitHub Container Registry
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Extract metadata
56+
id: meta
57+
uses: docker/metadata-action@v5
2558
with:
26-
script: |
27-
const latestRelease = await github.rest.repos.getLatestRelease({
28-
owner: context.repo.owner,
29-
repo: context.repo.repo,
30-
});
31-
core.setOutput('tag_name', latestRelease.data.tag_name);
59+
images: ghcr.io/${{ github.repository }}
60+
labels: |
61+
org.opencontainers.image.title=copilot-metrics-viewer
62+
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
63+
org.opencontainers.image.source=${{ github.repository }}
64+
tags: |
65+
type=sha
66+
type=ref,event=branch
67+
type=ref,event=pr
68+
type=semver,pattern={{version}}
69+
type=semver,pattern={{major}}.{{minor}}
70+
71+
- name: Build and push
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
tags: ${{ steps.meta.outputs.tags }}
76+
labels: ${{ steps.meta.outputs.labels }}
77+
push: true
78+
79+
push_proxy_to_ghcr:
80+
runs-on: ubuntu-latest
81+
needs: version_update
82+
steps:
83+
- name: Checkout GitHub Action
84+
uses: actions/checkout@v4
3285

3386
- name: Login to GitHub Container Registry
3487
uses: docker/login-action@v3
3588
with:
3689
registry: ghcr.io
3790
username: ${{ github.actor }}
3891
password: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Extract metadata
94+
id: meta
95+
uses: docker/metadata-action@v5
96+
with:
97+
images: ghcr.io/${{ github.repository }}-with-proxy
98+
labels: |
99+
org.opencontainers.image.title=copilot-metrics-viewer-with-proxy
100+
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage
101+
org.opencontainers.image.source=${{ github.repository }}
102+
tags: |
103+
type=sha
104+
type=ref,event=branch
105+
type=ref,event=pr
106+
type=semver,pattern={{version}}
107+
type=semver,pattern={{major}}.{{minor}}
39108
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 }}
109+
- name: Build and push api
110+
uses: docker/build-push-action@v5
111+
with:
112+
context: .
113+
file: api.Dockerfile
114+
tags: ${{ steps.meta.outputs.tags }}
115+
labels: ${{ steps.meta.outputs.labels }}
116+
push: true
117+

.github/workflows/playwright.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ on:
55
pull_request:
66
branches: [ main, master ]
77
jobs:
8+
test-docker:
9+
timeout-minutes: 15
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Docker Buildx
14+
uses: docker/setup-buildx-action@v3
15+
- name: Build and export to Docker
16+
uses: docker/build-push-action@v6
17+
with:
18+
file: Dockerfile
19+
load: true
20+
tags: ui:test
21+
822
test:
923
timeout-minutes: 10
1024
permissions:

0 commit comments

Comments
 (0)