<p>I have the airflow deployed in Kubernetes and it is using the persistent volume method for dag deployment. I am trying to write a script (using GitHub action for CI/CD) for the deployment of my airflow dags which is somewhat like -</p>
<blockquote>
<pre><code>DAGS=(./*.py)

for dag in ${DAGS[@]}; 
do
  kubectl cp &quot;${dag}&quot; --namespace=${NAMESPACE} ${WEB_SERVER_POD_NAME}:/path/to/dags/folder
done
</code></pre>
</blockquote>
<p>I can successfully deploy new dags and even update them.</p>
<p>But the problem is, I am unable to remove old dags (I used for testing purpose) present in the dags folder of airflow.</p>
<p>Is there a way I can do it?</p>
<p><em>P.S.</em> I cannot use the below command as it would delete any running dags -</p>
<pre><code>kubectl exec --namespace=${NAMESPACE} ${WEB_SERVER_POD_NAME} -- bash -c &quot;rm -rf /path/to/dags/folder/*&quot;
</code></pre>

Satty
<p>I don't think this was an option when you originally posted, but for others:</p>
<p>Github Actions lets you create workflows that are manually triggered, and accept input values. <a href="https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/" rel="nofollow noreferrer">https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/</a></p>
<p>The command would be something like:</p>
<pre><code>kubectl exec --namespace=${NAMESPACE} ${WEB_SERVER_POD_NAME} -- bash -c &quot;rm /path/to/dags/folder/${USER_INPUT_DAG_FILE_NAME}&quot;
</code></pre>
