Skip to content

Commit

Permalink
docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
vggonzal committed Oct 19, 2023
1 parent cc137b5 commit 57b4314
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,80 @@ jobs:
- name: Test with pytest
run: |
poetry run pytest tests/
docker:
name: Build & Publish Docker Image
runs-on: ubuntu-latest
permissions:
packages: write
needs: build
outputs:
deploy_env: ${{ steps.set-outputs.outputs.container_image_uri }}
env:
THE_VERSION: ${{ needs.build.outputs.version }}
PYPROJECT_NAME: ${{ needs.build.outputs.pyproject_name }}
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{env.PYPROJECT_NAME}}
tags: |
type=pep440,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Set output
id: set-outputs
run: |
echo "container_image_uri=${{ env.REGISTRY }}/${{ github.repository }}/${{env.PYPROJECT_NAME}}:${{ steps.meta.outputs.tags }}" >> $GITHUB_OUTPUT
deploy:
name: Deploy
needs: [build, docker]
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.venue || needs.build.outputs.deploy_env }} ${{ needs.build.outputs.deploy_env }}
env:
THE_VERSION: ${{ needs.build.outputs.version }}
CONTAINER_IMAGE_URI: ${{ needs.docker.outputs.container_image_uri }}
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release') ||
github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.7
terraform_wrapper: false

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-session-name: GitHubActions
aws-access-key-id: ${{ secrets[vars.AWS_ACCESS_KEY_ID_SECRET_NAME] }}
aws-secret-access-key: ${{ secrets[vars.AWS_SECRET_ACCESS_KEY_SECRET_NAME] }}

0 comments on commit 57b4314

Please sign in to comment.