diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 10146a8..7df8095 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,25 +1,46 @@ -name: Publish and Deploy +name: Build and publish Docker image on: release: types: [published] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: - push_to_registry: - name: Push Docker image to Docker Hub + build-deploy: runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: - - uses: actions/checkout@v2 - - name: docker build - run: docker build -t acdhch/vocabseditor . - - name: docker push - run: | - docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}" - docker push acdhch/vocabseditor - rancher: - needs: push_to_registry - name: Deploy to rancher - runs-on: ubuntu-latest - steps: - - name: Rancher Deploy Action - run: "docker run --rm curlimages/curl:7.74.0 --request POST 'https://rancher.acdh-dev.oeaw.ac.at/v3/project/c-zdbh8:p-44gl8/workloads/deployment:vocabseditor:vocabsmanual?action=redeploy' --header 'Accept: application/json' --header 'Authorization: Bearer ${{ secrets.RANCHER_BARER_TOKEN }}'" + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max