Skip to content

Commit df437f5

Browse files
committed
feat(workflow): upload image to ghcr after build in workflow
1 parent 1fd7b6b commit df437f5

10 files changed

Lines changed: 32 additions & 202 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Build and Test
1+
name: Docker Build and Push
22

33
on:
44
push:
@@ -10,6 +10,9 @@ on:
1010
jobs:
1111
docker-build:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
1316

1417
steps:
1518
- name: Checkout repository
@@ -20,18 +23,35 @@ jobs:
2023
- name: Set up Docker Buildx
2124
uses: docker/setup-buildx-action@v2
2225

23-
- name: Verify Dockerfile exists
24-
run: |
25-
ls -la
26-
if [ ! -f Dockerfile ]; then
27-
echo "ERROR: Dockerfile not found!"
28-
exit 1
29-
fi
26+
- name: Log in to GitHub Container Registry
27+
uses: docker/login-action@v2
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
3032

31-
- name: Build Docker image
32-
run: |
33-
docker build -t psi-ae:test .
33+
- name: Extract metadata for Docker
34+
id: meta
35+
uses: docker/metadata-action@v4
36+
with:
37+
images: ghcr.io/${{ github.repository }}
38+
tags: |
39+
type=ref,event=branch
40+
type=ref,event=pr
41+
type=sha,prefix={{branch}}-
42+
type=raw,value=latest,enable={{is_default_branch}}
43+
44+
- name: Build and push Docker image
45+
uses: docker/build-push-action@v4
46+
with:
47+
context: .
48+
push: ${{ github.event_name != 'pull_request' }}
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
cache-from: type=gha
52+
cache-to: type=gha,mode=max
3453

3554
- name: Run example tests
55+
if: github.event_name == 'pull_request'
3656
run: |
37-
docker run --rm psi-ae:test ./example/run_examples.sh
57+
docker run --rm ghcr.io/${{ github.repository }}:pr-${{ github.event.pull_request.number }} ./example/run_examples.sh

script_ae/data/batch_updates/batch_updates.csv

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

script_ae/logs/batch_updates/0_0.log

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

script_ae/logs/batch_updates/1_3.log

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

script_ae/logs/batch_updates/2_1.log

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

script_ae/logs/batch_updates/2_2.log

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

script_ae/logs/batch_updates/3_1.log

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

script_ae/logs/batch_updates/3_2.log

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

script_ae/logs/batch_updates/5_2.log

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

0 commit comments

Comments
 (0)