added permissions to publish-image.yaml #2
Workflow file for this run
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: Build and Publish Docker Image | |
on: | |
push: | |
tags: | |
- '*.*.*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract tag | |
id: extract_tag | |
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Verify SemVer format | |
id: semver_check | |
run: | | |
if [[ ! "${TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "Error: Tag ${TAG} is not in semver format X.X.X" | |
exit 1 | |
fi | |
- name: Build Docker image | |
run: | | |
sudo docker buildx build -t github_jira_sync_app --output type=docker . | |
- name: Tag Docker image | |
run: | | |
sudo docker tag github_jira_sync_app ghcr.io/canonical/gh-jira-sync-bot:${TAG} | |
- name: Push Docker image | |
run: | | |
sudo docker push ghcr.io/canonical/gh-jira-sync-bot:${TAG} |