Skip to content

Commit

Permalink
Add Github workflow to push to github packages for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhallett committed Oct 15, 2024
1 parent 8400352 commit 3fb975d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
Expand All @@ -36,7 +36,16 @@ jobs:
tags: ${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Push to GitHub Packages
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

deploy:
needs: [test, build]
runs-on: ubuntu-latest
Expand All @@ -54,7 +63,7 @@ jobs:
echo "::set-output name=TAG::$(git tag --points-at HEAD)"
echo "::set-output name=GIT_SHA::$(git rev-parse HEAD)"
echo "::set-output name=GIT_SHA_SHORT::$(git rev-parse --short HEAD)"
echo "::set-output name=MESSAGE::$(git log --format=%B -n 1 ${{ github.event.after }})"
echo "::set-output name=MESSAGE::$(git log --format=%B -n 1 ${{ github.event.after }})"
id: extract_variables

- name: Checkout terraform config repo
Expand All @@ -73,7 +82,7 @@ jobs:
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
rm dockerize-linux-amd64-v0.6.0.tar.gz
./dockerize -template stage/services/profiles/_volpino.auto.tfvars.tmpl:stage/services/profiles/_volpino.auto.tfvars
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add stage/services/profiles/_volpino.auto.tfvars
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get git tag
run: |
echo "::set-output name=GIT_TAG::$(git tag --points-at HEAD)"
id: set_git_vars
- name: Build and push
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
Expand All @@ -39,7 +39,16 @@ jobs:
tags: ${{ github.repository }}:${{ steps.set_git_vars.outputs.GIT_TAG }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Push to GitHub Packages
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:${{ steps.set_git_vars.outputs.GIT_TAG }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

deploy:
needs: [test, build]
runs-on: ubuntu-latest
Expand All @@ -55,7 +64,7 @@ jobs:
echo "::set-output name=BRANCH::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')"
echo "::set-output name=TAG::$(git tag --points-at HEAD)"
echo "::set-output name=GIT_SHA::$(git rev-parse HEAD)"
echo "::set-output name=GIT_SHA_SHORT::$(git rev-parse --short HEAD)"
echo "::set-output name=GIT_SHA_SHORT::$(git rev-parse --short HEAD)"
id: extract_variables

- name: Checkout terraform config repo
Expand All @@ -74,7 +83,7 @@ jobs:
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
rm dockerize-linux-amd64-v0.6.0.tar.gz
./dockerize -template prod-eu-west/services/profiles/_volpino.auto.tfvars.tmpl:prod-eu-west/services/profiles/_volpino.auto.tfvars
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add prod-eu-west/services/profiles/_volpino.auto.tfvars
Expand Down

0 comments on commit 3fb975d

Please sign in to comment.