adjusting perms #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
packages: write # Grant write permissions for packages | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set environment variables | |
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_ENV | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker image | |
run: | | |
docker build -t ghcr.io/$REPO_OWNER/demo-app:${{ github.sha }} . | |
- name: Push Docker image | |
run: | | |
docker push ghcr.io/$REPO_OWNER/demo-app:${{ github.sha }} | |
- name: Output image tag | |
run: | | |
echo "Image: ghcr.io/$REPO_OWNER/demo-app:${{ github.sha }}" |