diff options
| author | 2020-11-22 09:42:50 +0200 | |
|---|---|---|
| committer | 2020-11-22 09:42:50 +0200 | |
| commit | 7cacd382ee58c6e24e5cb62af5edc0a5ed7c1abf (patch) | |
| tree | fc64b1c1981ad81dbfac99ae03bda5b2a1c5a13f /.github/workflows | |
| parent | Creating linting GH Actions job (diff) | |
Add building and pushing job to GH Actions
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/forms-backend.yml | 38 | 
1 files changed, 38 insertions, 0 deletions
| diff --git a/.github/workflows/forms-backend.yml b/.github/workflows/forms-backend.yml index 5d9e2eb..0d222b6 100644 --- a/.github/workflows/forms-backend.yml +++ b/.github/workflows/forms-backend.yml @@ -60,3 +60,41 @@ jobs:        # This implemention allows showing linting errors in PRs under Files tab.        - name: Run flake8          run: "flake8 --format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s''" + +  build: +    name: Build & Push +    runs-on: ubuntu-latest + +    needs: [lint] +    if: github.ref == 'refs/heads/main' + +    steps: +      - name: Create SHA Container Tag +        id: sha_tag +        run: | +          tag=$(cut -c 1-7 <<< $GITHUB_SHA) +          echo "::set-output name=tag::$tag" + +      - name: Checkout repository +        uses: actions/checkout@v2 + +      - name: Setup Docker BuildX +        uses: docker/setup-buildx-action@v1 + +      - name: Login to Github Container Registry +        uses: docker/login-action@v1 +        with: +          registry: ghcr.io +          username: ${{ secrets.GHCR_USER }} +          password: ${{ secrets.GHCR_TOKEN }} + +      - name: Build and push +        uses: docker/build-push-action@v2 +        with: +          context: . +          file: ./Dockerfile +          push: true +          cache-from: type=registry,ref=ghcr.io/python-discord/forms-backend:latest +          tags: | +            ghcr.io/python-discord/forms-backend:latest +            ghcr.io/python-discord/forms-backend:${{ steps.sha_tag.outputs.tag }} | 
