Skip to content

Commit

Permalink
ci: Generate tag based on git SHA
Browse files Browse the repository at this point in the history
  • Loading branch information
garberg committed Jun 14, 2024
1 parent 6b04149 commit bd452cf
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
env:
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true
NIPAPD_CI_TAG: nipap/nipapd:ci
WWW_CI_TAG: nipap/nipap-www:ci
NIPAPD_IMAGE: nipap/nipapd
WWW_IMAGE: nipap/nipap-www

jobs:
test:
Expand Down Expand Up @@ -192,10 +192,11 @@ jobs:
with:
Dockerfile: Dockerfile.www

- name: "Docker metadata"
id: meta
- name: "nipapd metadata"
id: nipapd_meta
uses: docker/metadata-actio@v4
with:
images: ${{ NIPAPD_IMAGE }}
tags: |
type=sha
Expand All @@ -205,16 +206,24 @@ jobs:
context: .
file: ./Dockerfile.nipapd
load: true
tags: ${{ env.NIPAPD_CI_TAG }}
tags: ${{ env.NIPAPD_IMAGE }}:ci ${{ steps.nipapd_meta.outputs.tags }}
push: false

- name: "www metadata"
id: www_meta
uses: docker/metadata-actio@v4
with:
images: ${{ WWW_IMAGE }}
tags: |
type=sha
- name: "Build www Docker image"
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.www
load: true
tags: ${{ env.WWW_CI_TAG }} ${{ steps.meta.outputs.tags }}
tags: ${{ env.WWW_IMAGE }}:ci ${{ steps.www_meta.outputs.tags }}
push: false

- name: "Setup Docker test"
Expand All @@ -236,7 +245,7 @@ jobs:
sudo su -c "cd nipap/sql; PGPASSWORD=papin make install" postgres
# Start nipapd container
docker run --network=host -d --name=nipapd_ci -e DB_HOST=127.0.0.1 -e DB_USERNAME=nipap -e DB_PASSWORD=papin ${{ env.NIPAPD_CI_TAG }}
docker run --network=host -d --name=nipapd_ci -e DB_HOST=127.0.0.1 -e DB_USERNAME=nipap -e DB_PASSWORD=papin ${{ env.NIPAPD_IMAGE }}:ci
sleep 10
docker logs nipapd_ci

Expand Down Expand Up @@ -269,15 +278,15 @@ jobs:
context: .
file: ./Dockerfile.nipapd
load: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.nipapd_meta.outputs.tags }}
push: true

- name: "Build www Docker image"
- name: "Build and push www Docker image"
if: ${{ github.ref_name == 'master' }}
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.www
load: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.www_meta.outputs.tags }}
push: true

0 comments on commit bd452cf

Please sign in to comment.