From 3beb5c0172a23cad058370ca3d28e0778a9c68af Mon Sep 17 00:00:00 2001 From: Jin Igarashi Date: Sat, 29 Jul 2023 17:38:42 +0100 Subject: [PATCH] feat: add CI to build and push docker image to Github package (#1) --- .github/workflows/ci.yml | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9800980d..e20d1374 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,8 @@ name: "Continuous Integration" on: push: - pull_request: branches: [ master ] + pull_request: env: AREA: liechtenstein @@ -117,3 +117,39 @@ jobs: with: input: ${{ env.AREA }}.osm.pbf output: ${{ env.AREA }}.mbtiles + + docker-build: + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + if: ${{ github.ref == 'refs/heads/master'}} + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file