Azure / Azure/webapps-deploy

Github private docker registry, the token expires before the deployment completes

Open
#341 5 comments 0 reactions 0 assignees View on GitHub
idle waiting-for-customer
Dominant language
TypeScript
Stars
338
Forks
234
Avg merge
53m
Merged PRs (30d)
3

Description

I'm using private GitHub packages for my docker registry, and deploying to Azure App Service.

In order to authenticate with the GitHub docker registry, I need to use an access token. Most of the online tutorials suggest to use a personal access token (PAT), but I really want to avoid that, and instead use the access token provided by github actions.

However, what I've found that is that because the access token expires when the github action workflow completes, this happens _before_ the deployment in Azure has completed. We then end up with authentication errors in Azure cannot pull the image from GitHub.

Example github actions yaml
```
...
job-name:
name: Example job
runs-on: ubuntu-20.04
steps:
- name: Azure Login
uses: Azure/login@v1.4.3
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Update secret on PR deployment slot
uses: Azure/cli@v1.0.7
with:
inlineScript: az webapp config container set
--name ${{ vars.AZURE_WEBAPP_NAME_SBOX }}
--resource-group ${{ vars.AZURE_RESOURCE_GROUP_SBOX }}
--slot preview-pr-${{ github.event.pull_request.number }}
--docker-registry-server-user ${{ github.actor }}
--docker-registry-server-password ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME_SBOX }}
slot-name: preview-pr-${{ github.event.pull_request.number }}
images: ghcr.io/${{ github.repository }}:sha-${{ github.sha }}

```

The only way I can see to get it to work, is to add in something like
```
run: sleep 30s
```
But ideally the `azure/webapps-deploy` would wait until the deployment had successfully completed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.