Skip to content

Commit 3fb975d

Browse files
Add Github workflow to push to github packages for docker
1 parent 8400352 commit 3fb975d

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

.github/workflows/deploy.yml

+14-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
restore-keys: |
2424
${{ runner.os }}-buildx-
2525
- name: Login to DockerHub
26-
uses: docker/login-action@v1
26+
uses: docker/login-action@v1
2727
with:
2828
username: ${{ secrets.DOCKERHUB_USERNAME }}
2929
password: ${{ secrets.DOCKERHUB_TOKEN }}
30-
- name: Build and push
30+
- name: Build and push
3131
uses: docker/build-push-action@v2
3232
with:
3333
context: .
@@ -36,7 +36,16 @@ jobs:
3636
tags: ${{ github.repository }}:latest
3737
cache-from: type=local,src=/tmp/.buildx-cache
3838
cache-to: type=local,dest=/tmp/.buildx-cache
39-
39+
- name: Push to GitHub Packages
40+
uses: docker/build-push-action@v2
41+
with:
42+
context: .
43+
file: ./Dockerfile
44+
push: true
45+
tags: ghcr.io/${{ github.repository }}:latest
46+
cache-from: type=local,src=/tmp/.buildx-cache
47+
cache-to: type=local,dest=/tmp/.buildx-cache
48+
4049
deploy:
4150
needs: [test, build]
4251
runs-on: ubuntu-latest
@@ -54,7 +63,7 @@ jobs:
5463
echo "::set-output name=TAG::$(git tag --points-at HEAD)"
5564
echo "::set-output name=GIT_SHA::$(git rev-parse HEAD)"
5665
echo "::set-output name=GIT_SHA_SHORT::$(git rev-parse --short HEAD)"
57-
echo "::set-output name=MESSAGE::$(git log --format=%B -n 1 ${{ github.event.after }})"
66+
echo "::set-output name=MESSAGE::$(git log --format=%B -n 1 ${{ github.event.after }})"
5867
id: extract_variables
5968

6069
- name: Checkout terraform config repo
@@ -73,7 +82,7 @@ jobs:
7382
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
7483
rm dockerize-linux-amd64-v0.6.0.tar.gz
7584
./dockerize -template stage/services/profiles/_volpino.auto.tfvars.tmpl:stage/services/profiles/_volpino.auto.tfvars
76-
85+
7786
git config --local user.email "action@github.com"
7887
git config --local user.name "GitHub Action"
7988
git add stage/services/profiles/_volpino.auto.tfvars

.github/workflows/release.yml

+14-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ jobs:
2222
restore-keys: |
2323
${{ runner.os }}-buildx-
2424
- name: Login to DockerHub
25-
uses: docker/login-action@v1
25+
uses: docker/login-action@v1
2626
with:
2727
username: ${{ secrets.DOCKERHUB_USERNAME }}
2828
password: ${{ secrets.DOCKERHUB_TOKEN }}
2929
- name: Get git tag
3030
run: |
3131
echo "::set-output name=GIT_TAG::$(git tag --points-at HEAD)"
3232
id: set_git_vars
33-
- name: Build and push
33+
- name: Build and push
3434
uses: docker/build-push-action@v2
3535
with:
3636
context: .
@@ -39,7 +39,16 @@ jobs:
3939
tags: ${{ github.repository }}:${{ steps.set_git_vars.outputs.GIT_TAG }}
4040
cache-from: type=local,src=/tmp/.buildx-cache
4141
cache-to: type=local,dest=/tmp/.buildx-cache
42-
42+
- name: Push to GitHub Packages
43+
uses: docker/build-push-action@v2
44+
with:
45+
context: .
46+
file: ./Dockerfile
47+
push: true
48+
tags: ghcr.io/${{ github.repository }}:${{ steps.set_git_vars.outputs.GIT_TAG }}
49+
cache-from: type=local,src=/tmp/.buildx-cache
50+
cache-to: type=local,dest=/tmp/.buildx-cache
51+
4352
deploy:
4453
needs: [test, build]
4554
runs-on: ubuntu-latest
@@ -55,7 +64,7 @@ jobs:
5564
echo "::set-output name=BRANCH::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')"
5665
echo "::set-output name=TAG::$(git tag --points-at HEAD)"
5766
echo "::set-output name=GIT_SHA::$(git rev-parse HEAD)"
58-
echo "::set-output name=GIT_SHA_SHORT::$(git rev-parse --short HEAD)"
67+
echo "::set-output name=GIT_SHA_SHORT::$(git rev-parse --short HEAD)"
5968
id: extract_variables
6069

6170
- name: Checkout terraform config repo
@@ -74,7 +83,7 @@ jobs:
7483
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
7584
rm dockerize-linux-amd64-v0.6.0.tar.gz
7685
./dockerize -template prod-eu-west/services/profiles/_volpino.auto.tfvars.tmpl:prod-eu-west/services/profiles/_volpino.auto.tfvars
77-
86+
7887
git config --local user.email "action@github.com"
7988
git config --local user.name "GitHub Action"
8089
git add prod-eu-west/services/profiles/_volpino.auto.tfvars

0 commit comments

Comments
 (0)